Hi all:
I want one enabled QLineEdit widget(named testLE) to have the same background color when it is disabled.(It should look like a QLabel) The following is my code:
ui->testLE->setPalette(*palette);
ui->testLE->setFrame(false);
QColor *color = new QColor;
*color = palette->color(QPalette::Disabled,QPalette::Base);
palette->setColor(QPalette::Normal,QPalette::Base,*color);
ui->testLE->setPalette(*palette);
ui->testLE->setFrame(false);
To copy to clipboard, switch view to plain text mode
The above code can realize my idea. However when i click a button that opens an file-open-dialog, the background of the QLineEdit comes to default(white).
Could anyone plz explain why the background changes to default?
And could u plz tell me the way to keep it's color when other dialog popup?
QT.jpg
Bookmarks