本文整理汇总了C++中QComboBox::setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setStyleSheet方法的具体用法?C++ QComboBox::setStyleSheet怎么用?C++ QComboBox::setStyleSheet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setStyleSheet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encodingChanged
void ResultForm::encodingChanged(const QString &encoding)
{
QTextCodec *codec = QTextCodec::codecForName(encoding.toLatin1());
QComboBox *comboBox = qobject_cast<QComboBox *>(sender());
if (codec) {
if (comboBox)
comboBox->setStyleSheet("");
if (ui->requestRadio->isChecked()) {
ui->bodyText->setPlainText(codec->toUnicode(m_request->body));
} else if (ui->responseRadio->isChecked()) {
ui->bodyText->setPlainText(codec->toUnicode(m_response->body));
}
} else if (comboBox)
comboBox->setStyleSheet("QComboBox:editable:!on { background: #FF7777; color: white }");
}
示例2: refreshDisplay
void EasyViewWidget::refreshDisplay() {
if(this->layout()) {
qDeleteAll(Boxes);
Boxes.clear();
delete this->layout();
}
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
QComboBox* fileChoice = new QComboBox();
#if defined(_WIN32) && defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP) // Workaround render bug
QString style = "QComboBox QAbstractItemView { border: 1px solid gray }";
fileChoice->setStyleSheet(style);
#endif
layout->addWidget(fileChoice);
for (size_t Pos=0; Pos<C->Count_Get(); Pos++)
fileChoice->addItem( wstring2QString(C->Get(Pos, Stream_General, 0, __T("CompleteName"))), (int)Pos);
fileChoice->setCurrentIndex(FilePos);
connect(fileChoice,SIGNAL(currentIndexChanged(int)),SLOT(changeFilePos(int)));
QFrame *box;
QGroupBox *subBox;
for (size_t StreamPos=0; StreamPos<Stream_Max; StreamPos++) {
bool addBox = false;
box = new QFrame();
QHBoxLayout* boxLayout = new QHBoxLayout();
box->setLayout(boxLayout);
for (size_t Pos=0; Pos<Boxes_Count_Get(StreamPos); Pos++) {
subBox = createBox((stream_t)StreamPos,(int)Pos);
if(subBox!=NULL) {
boxLayout->addWidget(subBox);
addBox = true;
}
}
if(addBox) {
layout->addWidget(box);
Boxes.push_back(box);
}
}
layout->addStretch();
}
示例3: updateState
void MainWindow::updateState()
{
for (int i = 0; i < ui_->EventsTable->rowCount(); ++i)
{
QComboBox* level = dynamic_cast<QComboBox*>(ui_->EventsTable->cellWidget(i, 3));
if (level->currentText() == EVENT_LOW_RUS)
level->setStyleSheet("QComboBox { background-color:" + LOW_COLOR + "; }");
if (level->currentText() == EVENT_MIDDLE_RUS)
level->setStyleSheet("QComboBox { background-color:" + MIDDLE_COLOR + "; }");
if (level->currentText() == EVENT_HIGH_RUS)
level->setStyleSheet("QComboBox { background-color:" + HIGH_COLOR + "; }");
}
for (int i = 0; i < ui_->FriendsTable->rowCount(); ++i)
{
QComboBox* level = dynamic_cast<QComboBox*>(ui_->FriendsTable->cellWidget(i, 1));
if (level->currentText() == FRIEND_LOW_RUS)
level->setStyleSheet("QComboBox { background-color:" + HIGH_COLOR + "; }");
if (level->currentText() == FRIEND_MIDDLE_RUS)
level->setStyleSheet("QComboBox { background-color:" + MIDDLE_COLOR + "; }");
if (level->currentText() == FRIEND_HIGH_RUS)
level->setStyleSheet("QComboBox { background-color:" + LOW_COLOR + "; }");
}
}
示例4: createWidget
//.........这里部分代码省略.........
// === define update function ===
auto update = [=]() {
posComboBox->blockSignals(true);
posObject->blockSignals(true);
affectXCB->blockSignals(true);
affectYCB->blockSignals(true);
rotComboBox->blockSignals(true);
rotObject->blockSignals(true);
scaleComboBox->blockSignals(true);
scaleObject->blockSignals(true);
bool pModeDifference = false;
bool affectXDifference = false;
bool affectYDifference = false;
bool pIdDifference = false;
bool rModeDifference = false;
bool rIdDifference = false;
bool sModeDifference = false;
bool sIdDifference = false;
Mode pMode = ((ConstraintTag*) tags.first())->_positionMode;
bool affectX = ((ConstraintTag*) tags.first())->_affectX;
bool affectY = ((ConstraintTag*) tags.first())->_affectY;
quint64 pId = ((ConstraintTag*) tags.first())->_posId;
bool hasPId = ((ConstraintTag*) tags.first())->_hasPosId;
Mode rMode = ((ConstraintTag*) tags.first())->_rotationMode;
quint64 rId = ((ConstraintTag*) tags.first())->_rotId;
bool hasRId = ((ConstraintTag*) tags.first())->_hasRotId;
Mode sMode = ((ConstraintTag*) tags.first())->_scalationMode;
quint64 sId = ((ConstraintTag*) tags.first())->_scaleId;
bool hasSId = ((ConstraintTag*) tags.first())->_hasScaleId;
foreach (Tag* t, tags) {
ConstraintTag* ct = (ConstraintTag*) t;
if (ct->_positionMode != pMode) pModeDifference = true;
if (ct->_affectX != affectX) affectXDifference = true;
if (ct->_affectY != affectY) affectYDifference = true;
if ((ct->_hasPosId != hasPId)
|| (ct->_hasPosId && hasPId && ct->_posId != pId)) pIdDifference = true;
if (ct->_rotationMode != rMode) rModeDifference = true;
if ((ct->_hasRotId != hasRId)
|| (ct->_hasRotId && hasRId && ct->_rotId != rId)) rIdDifference = true;
if (ct->_scalationMode != sMode) sModeDifference = true;
if ((ct->_hasScaleId != hasSId)
|| (ct->_hasScaleId && hasSId && ct->_scaleId != sId)) sIdDifference = true;
}
if (pModeDifference) posComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else posComboBox->setStyleSheet("");
if (affectXDifference) affectXCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else affectXCB->setStyleSheet("");
if (affectYDifference) affectYCB->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else affectYCB->setStyleSheet("");
if (pIdDifference) posObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else posObject->setStyleSheet("");
posComboBox->setCurrentIndex(modeToIndex(pMode));
affectXCB->setChecked(affectX);
affectXCB->setEnabled(pMode != Mode::ignore);
affectYCB->setChecked(affectY);
affectYCB->setEnabled(pMode != Mode::ignore);
posObject->setEnabled(pMode != Mode::ignore);
if (hasPId)
posObject->setId(pId);
else
posObject->clear();
if (rModeDifference) rotComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else rotComboBox->setStyleSheet("");
if (rIdDifference) rotObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else rotObject->setStyleSheet("");
rotComboBox->setCurrentIndex(modeToIndex(rMode));
rotObject->setEnabled(rMode != Mode::ignore);
if (hasRId)
rotObject->setId(rId);
else
rotObject->clear();
if (sModeDifference) scaleComboBox->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else scaleComboBox->setStyleSheet("");
if (sIdDifference) scaleObject->setStyleSheet(QString("background-color:%1").arg(Property::MULTIPLE_VALUES_COLOR));
else scaleObject->setStyleSheet("");
scaleComboBox->setCurrentIndex(modeToIndex(sMode));
scaleObject->setEnabled(sMode != Mode::ignore);
if (hasSId)
scaleObject->setId(sId);
else
scaleObject->clear();
posComboBox->blockSignals(false);
posObject->blockSignals(false);
affectXCB->blockSignals(false);
affectYCB->blockSignals(false);
rotComboBox->blockSignals(false);
rotObject->blockSignals(false);
scaleComboBox->blockSignals(false);
scaleObject->blockSignals(false);
};