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?
Removing border of QLineEdit
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.
Use QLineEdit::setFrame()
for that. But yes, it isn't a static method. So, you have to call it on an object : myLineEdit->setFrame( false );
I know but I have about 200 QLineEdits, which means I would have to go threw and do this for every one. There isn't a way to just globally do it? –
Ebneter
© 2022 - 2024 — McMap. All rights reserved.