Removing a QLineEdit Border

I have a bunch of QLineEdit fields from which I want to remove borders. Ideally, I want to just do this with a single line of code, instead of not setting a border for each QLineEdit field. I am trying to use QLineEdit::setFrame(false);, but this returns an illegal call to a non-static member function. Suggestions?

+4
source share
2 answers

You can set the stylesheet for the application or for the parent of these changes:

window()->setStyleSheet("QLineEdit { border: none }");

or

window()->setStyleSheet("QLineEdit { qproperty-frame: false }");

The latter is equivalent to executing the following code:

for(auto ed : window()->findChildren<QLineEdit*>())
  ed->setFrame(false);

window()refers to QWidget * QWidget::window() const.

Since you want to do this across the entire application, you can simply set the stylesheet in the application:

qApp->setStyleSheet("QLineEdit { qproperty-frame: false }");

CSS . CSS .

+11

QLineEdit::setFrame(). , . , : myLineEdit->setFrame( false );

0

Source: https://habr.com/ru/post/1526224/


All Articles