当前位置: 首页>>代码示例>>C++>>正文


C++ QToolBar::actions方法代码示例

本文整理汇总了C++中QToolBar::actions方法的典型用法代码示例。如果您正苦于以下问题:C++ QToolBar::actions方法的具体用法?C++ QToolBar::actions怎么用?C++ QToolBar::actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QToolBar的用法示例。


在下文中一共展示了QToolBar::actions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:33,代码来源:tst_qtoolbar.cpp

示例2: 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);
}
开发者ID:yinyunqiao,项目名称:qtcreator,代码行数:26,代码来源:glsleditor.cpp

示例3: setupWindow

void specDockWidget::setupWindow(specActionLibrary* actions)
{
	// prepare main widget
	QMainWindow* widget = new QMainWindow(this) ;
	widget->setWindowFlags(Qt::Widget);
	setWidget(widget) ;

//	// get brushes
//	QPalette pal = palette() ;
//	QBrush activeWindow = pal.brush(QPalette::Active, QPalette::Window),
//			inactiveWindow = pal.brush(QPalette::Inactive, QPalette::Window) ;
//	if (activeWindow == inactiveWindow)
//		inactiveWindow.setColor(inactiveWindow.color().darker()) ;
//
//	pal.setBrush(QPalette::Inactive, QPalette::Window, inactiveWindow) ;
//	setPalette(pal) ;

	// add inner widgets
	QList<QWidget*> innerWidgets = mainWidgets() ;
	if(innerWidgets.size() == 1)
		widget->setCentralWidget(innerWidgets.first()) ;
	else
	{
		specSplitter* splitter = new specSplitter(Qt::Vertical, this) ;
		foreach(QWidget * innerWidget, innerWidgets)
		splitter->insertWidget(0, innerWidget);
		widget->setCentralWidget(splitter);
	}

	// add toolbars
	if(!actions)
		return ;
	QList<QWidget*> allWidgets ;
	allWidgets << this << innerWidgets ;
	foreach(QWidget * w, allWidgets)
	{
		specView* view = dynamic_cast<specView*>(w);
		specPlot* plot = dynamic_cast<specPlot*>(w) ;
		if(view && view->model())
		{
			view->setActionLibrary(actions) ;
			actions->addDragDropPartner(view->model());
			connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
				this, SLOT(selectionChanged(QItemSelection, QItemSelection))) ;
//			connect(view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
//				this, SLOT(currentChanged(QModelIndex,QModelIndex))) ;
		}
		if(plot)
		{
			Plot = plot ;
			actions->addPlot(plot) ;
		}
		QToolBar* toolbar = actions->toolBar(w) ;
		if(toolbar->actions().isEmpty())
			delete toolbar ;
		else
			widget->addToolBar(toolbar);

//		w->setPalette(pal);
	}
开发者ID:hvennekate,项目名称:data_element,代码行数:60,代码来源:specdockwidget.cpp

示例4: insertSeparator

void tst_QToolBar::insertSeparator()
{
    QToolBar tb;

    QAction action1(0);
    QAction action2(0);

    tb.addAction(&action1);
    tb.addAction(&action2);
    QAction *sep = tb.insertSeparator(&action2);

    QCOMPARE(tb.actions().count(), 3);
    QCOMPARE(tb.actions()[0], &action1);
    QCOMPARE(tb.actions()[1], sep);
    QCOMPARE(tb.actions()[2], &action2);

    tb.clear();
    QCOMPARE(tb.actions().count(), 0);
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:19,代码来源:tst_qtoolbar.cpp

示例5: 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);
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:46,代码来源:tst_qtoolbar.cpp

示例6: insertAction

void tst_QToolBar::insertAction()
{
    QToolBar tb;
    QAction action1(0);
    QAction action2(0);
    QAction action3(0);
    QAction action4(0);

    QCOMPARE(tb.actions().count(), 0);
    tb.insertAction(0, &action1);
    tb.insertAction(&action1, &action2);
    tb.insertAction(&action2, &action3);
    tb.insertAction(&action3, &action4);
    QCOMPARE(tb.actions().count(), 4);
    QCOMPARE(tb.actions()[0], &action4);
    QCOMPARE(tb.actions()[1], &action3);
    QCOMPARE(tb.actions()[2], &action2);
    QCOMPARE(tb.actions()[3], &action1);

    tb.clear();
    QCOMPARE(tb.actions().count(), 0);
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:22,代码来源:tst_qtoolbar.cpp

示例7: addAction

void tst_QToolBar::addAction()
{
    QToolBar tb;

    {
        QAction action(0);

        QCOMPARE(tb.actions().count(), 0);
        tb.addAction(&action);
        QCOMPARE(tb.actions().count(), 1);
        QCOMPARE(tb.actions()[0], &action);

        tb.clear();
        QCOMPARE(tb.actions().count(), 0);
    }

    {
        QString text = "text";
        QPixmap pm(32, 32);
        pm.fill(Qt::blue);
        QIcon icon = pm;

        QAction *action1 = tb.addAction(text);
        QCOMPARE(text, action1->text());

        QAction *action2 = tb.addAction(icon, text);
        QCOMPARE(icon, action2->icon());
        QCOMPARE(text, action2->text());

        QAction *action3 = tb.addAction(text, this, SLOT(slot()));
        QCOMPARE(text, action3->text());

        QAction *action4 = tb.addAction(icon, text, this, SLOT(slot()));
        QCOMPARE(icon, action4->icon());
        QCOMPARE(text, action4->text());

        QCOMPARE(tb.actions().count(), 4);
        QCOMPARE(tb.actions()[0], action1);
        QCOMPARE(tb.actions()[1], action2);
        QCOMPARE(tb.actions()[2], action3);
        QCOMPARE(tb.actions()[3], action4);

        tb.clear();
        QCOMPARE(tb.actions().count(), 0);
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:46,代码来源:tst_qtoolbar.cpp


注:本文中的QToolBar::actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。