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:

Qt Code:
  1. QColor *color = new QColor;
  2. *color = palette->color(QPalette::Disabled,QPalette::Base);
  3. palette->setColor(QPalette::Normal,QPalette::Base,*color);
  4. ui->testLE->setPalette(*palette);
  5. 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