本文整理汇总了C++中QComboBox::setFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QComboBox::setFont方法的具体用法?C++ QComboBox::setFont怎么用?C++ QComboBox::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QComboBox
的用法示例。
在下文中一共展示了QComboBox::setFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenAdjustWidgetAppearanceToOS
void QtHelpers::GenAdjustWidgetAppearanceToOS(QWidget *rootWidget)
{
if (rootWidget == NULL)
return;
QObject *child = NULL;
QObjectList Containers;
QObject *container = NULL;
QStringList DoNotAffect;
// Make an exception list (Objects not to be affected)
DoNotAffect.append("aboutTitleLabel"); // about Dialog
DoNotAffect.append("aboutVersionLabel"); // about Dialog
DoNotAffect.append("aboutCopyrightLabel"); // about Dialog
DoNotAffect.append("aboutUrlLabel"); // about Dialog
DoNotAffect.append("aboutLicenseLabel"); // about Dialog
// Set sizes according to OS:
#ifdef __APPLE__
int ButtonHeight = 35;
int cmbxHeight = 30;
QFont cntrlFont("Myriad Pro", 14);
QFont txtFont("Myriad Pro", 14);
#elif _WIN32 // Win XP/7
int ButtonHeight = 24;
int cmbxHeight = 20;
QFont cntrlFont("MS Shell Dlg 2", 8);
QFont txtFont("MS Shell Dlg 2", 8);
#else
int ButtonHeight = 24;
int cmbxHeight = 24;
QFont cntrlFont("Ubuntu Condensed", 10);
QFont txtFont("Ubuntu", 10);
#endif
// Append root to containers
Containers.append(rootWidget);
while (!Containers.isEmpty())
{
container = Containers.takeFirst();
if (container != NULL)
{
for (int ChIdx=0; ChIdx < container->children().size(); ChIdx++)
{
child = container->children()[ChIdx];
if (!child->isWidgetType() || DoNotAffect.contains(child->objectName()))
continue;
// Append containers to Stack for recursion
if (child->children().size() > 0)
Containers.append(child);
else
{
// Cast child object to button and label
// (if the object is not of the correct type, it will be NULL)
QPushButton *button = qobject_cast<QPushButton *>(child);
QLabel *label = qobject_cast<QLabel *>(child);
QComboBox *cmbx = qobject_cast<QComboBox *>(child);
QLineEdit *ln = qobject_cast<QLineEdit *>(child);
QTreeWidget *tree = qobject_cast<QTreeWidget *>(child);
QPlainTextEdit *plain = qobject_cast<QPlainTextEdit *>(child);
QCheckBox *check = qobject_cast<QCheckBox *>(child);
if (button != NULL)
{
button->setMinimumHeight(ButtonHeight); // Win
button->setMaximumHeight(ButtonHeight); // Win
button->setFont(cntrlFont);
}
else if (cmbx != NULL)
{
cmbx->setFont(cntrlFont);
cmbx->setMaximumHeight(cmbxHeight);
}
else if (label != NULL)
label->setFont(txtFont);
else if (ln != NULL)
ln->setFont(txtFont);
else if (tree != NULL)
{
tree->header()->setFont(txtFont);
}
else if (plain != NULL)
plain->setFont(txtFont);
else if (check != NULL)
check->setFont(txtFont);
}
}
}
}
}