本文整理汇总了C++中QComboBox::setPalette方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setPalette方法的具体用法?C++ QComboBox::setPalette怎么用?C++ QComboBox::setPalette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setPalette方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createEditor
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QComboBox *comboDelegate = new QComboBox(parent);
comboDelegate->setModel(model);
comboDelegate->setEditable(true);
comboDelegate->setAutoCompletion(true);
comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion);
comboDelegate->view()->setEditTriggers(QAbstractItemView::AllEditTriggers);
comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString)));
connect(comboDelegate->lineEdit(), SIGNAL(editingFinished()), this, SLOT(testActivation()));
connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation()));
currCombo.comboEditor = comboDelegate;
currCombo.currRow = index.row();
currCombo.model = const_cast<QAbstractItemModel*>(index.model());
// Current display of things on Gnome3 looks like shit, so
// let`s fix that.
if (isGnome3Session()) {
QPalette p;
p.setColor(QPalette::Window, QColor(Qt::white));
p.setColor(QPalette::Base, QColor(Qt::white));
comboDelegate->lineEdit()->setPalette(p);
comboDelegate->setPalette(p);
}
return comboDelegate;
}
示例2: setEditorData
void IColDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
if (!comboBox) return;
int pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly);
if( pos != -1){
comboBox->setCurrentIndex(pos);
}
else{
comboBox->addItem(index.model()->data(index).toString());
pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly);
comboBox->setCurrentIndex(pos);
}
if( _p->isActive() ){
//set background color
_parent->currentItem()->setBackgroundColor( _p->isErrorCol( _type, comboBox->currentText().toStdString() ) ?
QColor(184,16,0,180) : QColor(32,140,64,180) );
//set background color from (combobox)
QPalette pal = comboBox->palette();
pal.setColor(QPalette::Base, _p->isErrorCol( _type, comboBox->currentText().toStdString() ) ?
QColor(164,32,16) : QColor(32,140,64) );
pal.setColor(QPalette::Text, QColor(255,255,255) );
comboBox->setPalette(pal);
}
}
示例3: QComboBox
QWidget *Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & index) const
{
/*QSpinBox *editor = new QSpinBox(parent);
editor->setFrame(false);
editor->setMinimum(0);
editor->setMaximum(100);*/
QComboBox *editor = new QComboBox(parent);
QPalette pal = editor->palette();
pal.setColor(QPalette::HighlightedText, QColor(Qt::white));
editor->setPalette(pal);
//editor->addItems((QStringList() << list_defTcontrol));
return editor;
}
示例4: setModelData
void IColDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
if (!comboBox) return;
model->setData(index, comboBox->currentText());
//update the processor
_p->getCols( INPUT, _name )[ index.row() ]->setValue( comboBox->currentText().toStdString() );
_msc->consistencyCheck();
if( _p->isActive() ){
//set background color
_parent->currentItem()->setBackgroundColor( _p->isErrorCol( _type, comboBox->currentText().toStdString() ) ?
QColor(184,16,0,180) : QColor(32,140,64,180) );
//set background color from (combobox)
QPalette pal = comboBox->palette();
pal.setColor(QPalette::Base, _p->isErrorCol( _type, comboBox->currentText().toStdString() ) ?
QColor(164,32,16) : QColor(32,140,64) );
pal.setColor(QPalette::Text, QColor(255,255,255) );
comboBox->setPalette(pal);
}
}