本文整理汇总了C++中QToolBar::insertWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::insertWidget方法的具体用法?C++ QToolBar::insertWidget怎么用?C++ QToolBar::insertWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::insertWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createToolBar
void GLSLTextEditorWidget::createToolBar(GLSLEditorEditable *editable)
{
m_outlineCombo = new QComboBox;
m_outlineCombo->setMinimumContentsLength(22);
// ### m_outlineCombo->setModel(m_outlineModel);
QTreeView *treeView = new QTreeView;
treeView->header()->hide();
treeView->setItemsExpandable(false);
treeView->setRootIsDecorated(false);
m_outlineCombo->setView(treeView);
treeView->expandAll();
//m_outlineCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
// Make the combo box prefer to expand
QSizePolicy policy = m_outlineCombo->sizePolicy();
policy.setHorizontalPolicy(QSizePolicy::Expanding);
m_outlineCombo->setSizePolicy(policy);
QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());
QList<QAction*> actions = toolBar->actions();
toolBar->insertWidget(actions.first(), m_outlineCombo);
}
示例2:
QAction * QToolBarProto::insertWidget ( QAction * before, QWidget * widget )
{
QToolBar *item = qscriptvalue_cast<QToolBar*>(thisObject());
if (item)
return item->insertWidget(before, widget);
return 0;
}
示例3: insertWidget
void tst_QToolBar::insertWidget()
{
QToolBar tb;
QWidget w(&tb);
QAction action1(0);
QAction action2(0);
tb.addAction(&action1);
tb.addAction(&action2);
QAction *widget = tb.insertWidget(&action2, &w);
QCOMPARE(tb.actions().count(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], widget);
QCOMPARE(tb.actions()[2], &action2);
// it should be possible to reuse the action returned by
// addWidget() to place the widget somewhere else in the toolbar
tb.removeAction(widget);
QCOMPARE(tb.actions().count(), 2);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], &action2);
tb.insertAction(&action1, widget);
QCOMPARE(tb.actions().count(), 3);
QCOMPARE(tb.actions()[0], widget);
QCOMPARE(tb.actions()[1], &action1);
QCOMPARE(tb.actions()[2], &action2);
tb.clear();
QCOMPARE(tb.actions().count(), 0);
{
QToolBar tb;
QPointer<QWidget> widget = new QWidget;
QAction *action = tb.addWidget(widget);
QVERIFY(action->parent() == &tb);
QToolBar tb2;
tb.removeAction(action);
tb2.addAction(action);
QVERIFY(widget && widget->parent() == &tb2);
QVERIFY(action->parent() == &tb2);
}
}