本文整理汇总了C++中QComboBox::palette方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::palette方法的具体用法?C++ QComboBox::palette怎么用?C++ QComboBox::palette使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::palette方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: 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);
}
}