本文整理汇总了C++中QToolBar::style方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::style方法的具体用法?C++ QToolBar::style怎么用?C++ QToolBar::style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::style方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMarginAndSpacing
void QToolBarLayout::updateMarginAndSpacing()
{
QToolBar *tb = qobject_cast<QToolBar*>(parentWidget());
if (!tb)
return;
QStyle *style = tb->style();
QStyleOptionToolBar opt;
tb->initStyleOption(&opt);
setMargin(style->pixelMetric(QStyle::PM_ToolBarItemMargin, &opt, tb)
+ style->pixelMetric(QStyle::PM_ToolBarFrameWidth, &opt, tb));
setSpacing(style->pixelMetric(QStyle::PM_ToolBarItemSpacing, &opt, tb));
}
示例2:
QToolBar * DesignNetFormManager::createEditorToolBar() const
{
QToolBar *editorToolBar = new QToolBar;
const QList<Core::Id>::const_iterator cend = d->m_toolActionIds.constEnd();
for (QList<Core::Id>::const_iterator it = d->m_toolActionIds.constBegin(); it != cend; ++it)
{
Core::Command *cmd = Core::ActionManager::instance()->command(*it);
QAction *action = cmd->action();
if (!action->icon().isNull())
editorToolBar->addAction(action);
}
const int size = editorToolBar->style()->pixelMetric(QStyle::PM_SmallIconSize);
editorToolBar->setIconSize(QSize(size, size));
editorToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
return editorToolBar;
}
示例3:
QToolBar *FormEditorW::createEditorToolBar() const
{
QToolBar *editorToolBar = new QToolBar;
const QList<Id>::const_iterator cend = m_toolActionIds.constEnd();
for (QList<Id>::const_iterator it = m_toolActionIds.constBegin(); it != cend; ++it) {
Command *cmd = ActionManager::command(*it);
QTC_ASSERT(cmd, continue);
QAction *action = cmd->action();
if (!action->icon().isNull()) // Simplify grid has no action yet
editorToolBar->addAction(action);
}
const int size = editorToolBar->style()->pixelMetric(QStyle::PM_SmallIconSize);
editorToolBar->setIconSize(QSize(size, size));
editorToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
return editorToolBar;
}
示例4: iconSize
void tst_QToolBar::iconSize()
{
{
QToolBar tb;
QSignalSpy spy(&tb, SIGNAL(iconSizeChanged(QSize)));
// the default is determined by the style
const int metric = tb.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
const QSize defaultIconSize = QSize(metric, metric);
const QSize smallIconSize = QSize(metric / 2, metric / 2);
const QSize largeIconSize = QSize(metric * 2, metric * 2);
QCOMPARE(tb.iconSize(), defaultIconSize);
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(spy.count(), 0);
spy.clear();
tb.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), largeIconSize);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().first().toSize(), largeIconSize);
// no-op
spy.clear();
tb.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), largeIconSize);
QCOMPARE(spy.count(), 0);
spy.clear();
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().first().toSize(), defaultIconSize);
// no-op
spy.clear();
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(spy.count(), 0);
spy.clear();
tb.setIconSize(smallIconSize);
QCOMPARE(tb.iconSize(), smallIconSize);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.first().first().toSize(), smallIconSize);
// no-op
spy.clear();
tb.setIconSize(smallIconSize);
QCOMPARE(tb.iconSize(), smallIconSize);
QCOMPARE(spy.count(), 0);
// setting the icon size to an invalid QSize will reset the
// iconSize property to the default
tb.setIconSize(QSize());
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(spy.size(), 1);
QCOMPARE(spy.first().first().toSize(), defaultIconSize);
spy.clear();
}
{
QMainWindow mw;
QToolBar tb;
QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize)));
QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize)));
// the default is determined by the style
const int metric = tb.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
const QSize defaultIconSize = QSize(metric, metric);
const QSize smallIconSize = QSize(metric / 2, metric / 2);
const QSize largeIconSize = QSize(metric * 2, metric * 2);
mw.setIconSize(smallIconSize);
// explicitly set it to the default
tb.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(tbSpy.count(), 0);
mw.addToolBar(&tb);
// tb icon size should not change since it has been explicitly set
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(tbSpy.count(), 0);
mw.setIconSize(largeIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(tbSpy.count(), 0);
mw.setIconSize(defaultIconSize);
QCOMPARE(tb.iconSize(), defaultIconSize);
QCOMPARE(tbSpy.count(), 0);
mw.setIconSize(smallIconSize);
//.........这里部分代码省略.........