本文整理汇总了C++中QToolBar::removeAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::removeAction方法的具体用法?C++ QToolBar::removeAction怎么用?C++ QToolBar::removeAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QToolBar
的用法示例。
在下文中一共展示了QToolBar::removeAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addWidget
void tst_QToolBar::addWidget()
{
QToolBar tb;
QWidget w(&tb);
QAction action1(0);
QAction action2(0);
tb.addAction(&action1);
QAction *widget = tb.addWidget(&w);
tb.addAction(&action2);
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.addAction(widget);
QCOMPARE(tb.actions().count(), 3);
QCOMPARE(tb.actions()[0], &action1);
QCOMPARE(tb.actions()[1], &action2);
QCOMPARE(tb.actions()[2], widget);
tb.clear();
QCOMPARE(tb.actions().count(), 0);
}
示例2: 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);
}
}