QLineEmit* le = new QLineEmit(this);qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0.462745, 0.454902, 0.423529)QComboBox* combo = new QComboBox(this);combo->setEditable(true);combo->setLineEdit(le);qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0, 0, 0)
void QComboBox::setLineEdit(QLineEdit *edit){//... edit->setText(currentText()); d->lineEdit = edit; if (d->lineEdit->parent() != this) d->lineEdit->setParent(this); d->lineEdit->setFrame(false); d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); d->lineEdit->setFocusProxy(this); d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);//... if (isVisible()) d->lineEdit->show();}
C++ (Qt)MainWindow::MainWindow( QWidget *parent ) : QDialog( parent ){ QLineEdit* le = new QLineEdit(this); qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color(); //QColor(ARGB 1, 0.462745, 0.454902, 0.423529) QComboBox* combo = new QComboBox(this); combo->setEditable(true); combo->setLineEdit(le); qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color(); //QColor(ARGB 1, 0, 0, 0)}
QColor(ARGB 1, 0.494118, 0.490196, 0.486275) QColor(ARGB 1, 0.494118, 0.490196, 0.486275)
C++ (Qt)class MyLineEdit : public QLineEdit{ Q_OBJECT public: explicit MyLineEdit(QWidget* parent = 0); protected: void paintEvent(QPaintEvent* event);}; MyLineEdit::MyLineEdit(QWidget* parent) : QLineEdit(parent){} void MyLineEdit::paintEvent(QPaintEvent* event){qDebug() << "MyLineEdit::paintEvent:" << palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0, 0, 0) QLineEdit::paintEvent(event);qDebug() << "MyLineEdit::paintEvent:" << palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0, 0, 0)} //... MyLineEdit* le = new MyLineEdit(this);qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0.462745, 0.454902, 0.423529) QComboBox* combo = new QComboBox(this);combo->setEditable(true);combo->setLineEdit(le);qDebug() << le->palette().brush(QPalette::Disabled, QPalette::Text).color();//QColor(ARGB 1, 0.462745, 0.454902, 0.423529)
QPalette palette = patternComboBox->palette(); QColor c(Qt::red); if(rx.isValid()) c = textEdit->palette().color(QPalette::Text); palette.setColor(QPalette::Text, c); patternComboBox->setPalette(palette);
QPalette palette = patternComboBox->palette(); QColor c(Qt::red); if(rx.isValid()) c = textEdit->palette().color(QPalette::Active, QPalette::Text); palette.setColor(QPalette::Active, QPalette::Text, c); patternComboBox->setPalette(palette);