本文整理汇总了C++中QStringListModel::blockSignals方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringListModel::blockSignals方法的具体用法?C++ QStringListModel::blockSignals怎么用?C++ QStringListModel::blockSignals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringListModel
的用法示例。
在下文中一共展示了QStringListModel::blockSignals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _q_updateModel
void QFontComboBoxPrivate::_q_updateModel()
{
Q_Q(QFontComboBox);
const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
QStringListModel *m = qobject_cast<QStringListModel *>(q->model());
if (!m)
return;
QFontFamilyDelegate *delegate = qobject_cast<QFontFamilyDelegate *>(q->view()->itemDelegate());
QFontDatabase::WritingSystem system = delegate ? delegate->writingSystem : QFontDatabase::Any;
QFontDatabase fdb;
QStringList list = fdb.families(system);
QStringList result;
int offset = 0;
QFontInfo fi(currentFont);
for (int i = 0; i < list.size(); ++i) {
if ((filters & scalableMask) && (filters & scalableMask) != scalableMask) {
if (bool(filters & QFontComboBox::ScalableFonts) != fdb.isSmoothlyScalable(list.at(i)))
continue;
}
if ((filters & spacingMask) && (filters & spacingMask) != spacingMask) {
if (bool(filters & QFontComboBox::MonospacedFonts) != fdb.isFixedPitch(list.at(i)))
continue;
}
result += list.at(i);
if (list.at(i) == fi.family() || list.at(i).startsWith(fi.family() + QLatin1String(" [")))
offset = result.count() - 1;
}
list = result;
//we need to block the signals so that the model doesn't emit reset
//this prevents the current index from changing
//it will be updated just after this
///TODO: we should finda way to avoid blocking signals and have a real update of the model
const bool old = m->blockSignals(true);
m->setStringList(list);
m->blockSignals(old);
if (list.isEmpty()) {
if (currentFont != QFont()) {
currentFont = QFont();
emit q->currentFontChanged(currentFont);
}
} else {
q->setCurrentIndex(offset);
}
}