I have a bunch of QLineEdit
boxes that I want to remove the borders from. Ideally I want to just do this with one line of code, rather than having to set no border for each QLineEdit
box. I am trying to use QLineEdit::setFrame(false);
but this returns illegal call of non-static member function. Suggestions?
You can set the style sheet for the application, or for the parent of those line edits:
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);
The window()
refers to QWidget * QWidget::window() const
.
Since you want to do it application-wide, you can simply set the style sheet on the application:
qApp->setStyleSheet("QLineEdit { qproperty-frame: false }");
You can further use CSS selectors to override the frame on certain objects. You've got the power of CSS at your disposal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With