本文整理汇总了C++中QCheckBox::blockSignals方法的典型用法代码示例。如果您正苦于以下问题:C++ QCheckBox::blockSignals方法的具体用法?C++ QCheckBox::blockSignals怎么用?C++ QCheckBox::blockSignals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCheckBox
的用法示例。
在下文中一共展示了QCheckBox::blockSignals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCheckBox
WidgetParameterBool::WidgetParameterBool(ParameterPtrT<bool> parameter)
: WidgetParameter<bool>(parameter)
{
QCheckBox* checkBox = new QCheckBox(this);
checkBox->setChecked(parameter->lastValue());
checkBox->move(0,0);
parameter->addNewInternalValueCallback([checkBox, this](bool value){
checkBox->blockSignals(true);
checkBox->setChecked(value);
checkBox->blockSignals(false);
});
BOOST_VERIFY(connect(checkBox, SELECT<bool>::OVERLOAD_OF(&QCheckBox::clicked), [this](bool b) {
mParameter->set(b);
}));
mWidget = checkBox;
}
示例2: updateWidget
void EncTtsCfgGui::updateWidget()
{
// get sender setting
EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender());
if(setting == NULL) return;
// get corresponding widget
QWidget* widget = m_settingsWidgetsMap.value(setting);
// update Widget based on setting type
switch(setting->type())
{
case EncTtsSetting::eDOUBLE:
{
QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget;
spinbox->setMinimum(setting->min().toDouble());
spinbox->setMaximum(setting->max().toDouble());
spinbox->blockSignals(true);
spinbox->setValue(setting->current().toDouble());
spinbox->blockSignals(false);
break;
}
case EncTtsSetting::eINT:
{
QSpinBox* spinbox = (QSpinBox*) widget;
spinbox->setMinimum(setting->min().toInt());
spinbox->setMaximum(setting->max().toInt());
spinbox->blockSignals(true);
spinbox->setValue(setting->current().toInt());
spinbox->blockSignals(false);
break;
}
case EncTtsSetting::eSTRING:
{
QLineEdit* lineedit = (QLineEdit*) widget;
lineedit->blockSignals(true);
lineedit->setText(setting->current().toString());
lineedit->blockSignals(false);
break;
}
case EncTtsSetting::eREADONLYSTRING:
{
QLabel* label = (QLabel*) widget;
label->blockSignals(true);
label->setText(setting->current().toString());
label->blockSignals(false);
break;
}
case EncTtsSetting::eSTRINGLIST:
{
QComboBox* combobox = (QComboBox*) widget;
combobox->blockSignals(true);
combobox->clear();
combobox->addItems(setting->list());
int index = combobox->findText(setting->current().toString());
combobox->setCurrentIndex(index);
combobox->blockSignals(false);
break;
}
case EncTtsSetting::eBOOL:
{
QCheckBox* checkbox = (QCheckBox*) widget;
checkbox->blockSignals(true);
checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
checkbox->blockSignals(false);
break;
}
default:
{
LOG_WARNING() << "unknown EncTTsSetting";
break;
}
}
}
示例3: createWidget
QWidget* ConstraintTag::createWidget(QList<Tag *> tags, QWidget *parent)
{
// === Create Widget ===
QWidget* base = new QWidget(parent);
QHBoxLayout* horLayout = new QHBoxLayout();
QStringList comboboxItems = QStringList() << tr("ignore") << tr("local") << tr("global");
QVBoxLayout* posLayout = new QVBoxLayout();
posLayout->setSpacing(0);
posLayout->setContentsMargins(0,0,0,0);
QComboBox* posComboBox = new QComboBox(base);
posComboBox->addItems(comboboxItems);
posLayout->addWidget(posComboBox);
QCheckBox* affectXCB = new QCheckBox("x", base);
QCheckBox* affectYCB = new QCheckBox("y", base);
QHBoxLayout* l = new QHBoxLayout();
l->setContentsMargins(0,0,0,0);
l->setSpacing(0);
l->addWidget(affectXCB);
l->addWidget(affectYCB);
posLayout->addLayout(l);
posLayout->addStretch();
ObjectEdit* posObject = new ObjectEdit(base);
posObject->setProject(tags.first()->owner()->project());
posLayout->addWidget(posObject);
QVBoxLayout* rotLayout = new QVBoxLayout();
rotLayout->setSpacing(0);
rotLayout->setContentsMargins(0,0,0,0);
QComboBox* rotComboBox = new QComboBox(base);
rotComboBox->addItems(comboboxItems);
rotLayout->addWidget(rotComboBox);
rotLayout->addStretch();
ObjectEdit* rotObject = new ObjectEdit(base);
rotObject->setProject(tags.first()->owner()->project());
rotLayout->addWidget(rotObject);
QVBoxLayout* scaleLayout = new QVBoxLayout();
scaleLayout->setSpacing(0);
scaleLayout->setContentsMargins(0,0,0,0);
QComboBox* scaleComboBox = new QComboBox(base);
scaleComboBox->addItems(comboboxItems);
scaleLayout->addWidget(scaleComboBox);
scaleLayout->addStretch();
ObjectEdit* scaleObject = new ObjectEdit(base);
scaleObject->setProject(tags.first()->owner()->project());
scaleLayout->addWidget(scaleObject);
horLayout->addLayout(posLayout);
horLayout->addLayout(rotLayout);
horLayout->addLayout(scaleLayout);
// === end create Widget ===
// === 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;
//.........这里部分代码省略.........
示例4: propertyUpdated
void protoObject::propertyUpdated(QString propertyName){
QObject *receiver = mapper->mapping(propertyName);
QWidget *widget;
if (receiver) return; //if not binding, just leave
widget = qobject_cast<QLabel*>(receiver);
if (widget) {
QLabel* edit = qobject_cast<QLabel*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(edit->text().arg(value));
edit->blockSignals(false);
};
widget = qobject_cast<QLineEdit*>(receiver);
if (widget) {
QLineEdit* edit = qobject_cast<QLineEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QComboBox*>(receiver);
if (widget) {
QComboBox* edit = qobject_cast<QComboBox*>(receiver);
edit->blockSignals(true);
edit->setCurrentIndex(edit->findData(this->property(propertyName.toLatin1()), Qt::UserRole));
edit->blockSignals(false);
};
widget = qobject_cast<QRadioButton*>(receiver);
if (widget) {
QRadioButton* edit = qobject_cast<QRadioButton*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QCheckBox*>(receiver);
if (widget) {
QCheckBox* edit = qobject_cast<QCheckBox*>(receiver);
bool value = this->property(propertyName.toLatin1()).toBool();
edit->blockSignals(true);
edit->setChecked(value);
edit->blockSignals(false);
};
widget = qobject_cast<QPlainTextEdit*>(receiver);
if (widget) {
QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(receiver);
QString value = this->property(propertyName.toLatin1()).toString();
edit->blockSignals(true);
edit->setPlainText(value);
edit->blockSignals(false);
};
widget = qobject_cast<QSpinBox*>(receiver);
if (widget) {
QSpinBox* edit = qobject_cast<QSpinBox*>(receiver);
int value = this->property(propertyName.toLatin1()).toInt();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDoubleSpinBox*>(receiver);
if (widget) {
QDoubleSpinBox* edit = qobject_cast<QDoubleSpinBox*>(receiver);
double value = this->property(propertyName.toLatin1()).toDouble();
edit->blockSignals(true);
edit->setValue(value);
edit->blockSignals(false);
};
widget = qobject_cast<QDateTimeEdit*>(receiver);
if (widget) {
QDateTimeEdit* edit = qobject_cast<QDateTimeEdit*>(receiver);
QDateTime value = this->property(propertyName.toLatin1()).toDateTime();
edit->blockSignals(true);
edit->setDateTime(value);
edit->blockSignals(false);
};
}