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


C++ QMenu::setTearOffEnabled方法代码示例

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


在下文中一共展示了QMenu::setTearOffEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: tearOff

void tst_QMenu::tearOff()
{
    QWidget widget;
    QMenu *menu = new QMenu(&widget);
    QVERIFY(!menu->isTearOffEnabled()); //default value
    menu->setTearOffEnabled(true);
    menu->addAction("aaa");
    menu->addAction("bbb");
    QVERIFY(menu->isTearOffEnabled());

    widget.show();
    widget.activateWindow();
    QVERIFY(QTest::qWaitForWindowActive(&widget));
    menu->popup(QPoint(0,0));
    QVERIFY(QTest::qWaitForWindowActive(menu));
    QVERIFY(!menu->isTearOffMenuVisible());

    QTest::mouseClick(menu, Qt::LeftButton, 0, QPoint(3, 3), 10);
    QTRY_VERIFY(menu->isTearOffMenuVisible());
    QPointer<QMenu> torn = 0;
    foreach (QWidget *w, QApplication::allWidgets()) {
        if (w->inherits("QTornOffMenu")) {
            torn = static_cast<QMenu *>(w);
            break;
        }
    }
    QVERIFY(torn);
    QVERIFY(torn->isVisible());

    menu->hideTearOffMenu();
    QVERIFY(!menu->isTearOffMenuVisible());
    QVERIFY(!torn->isVisible());
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例2: recent


//.........这里部分代码省略.........
	m_pMenuViewRecip->addAction(m_pSnapSmallq);

	QAction *pKeepAbsKiKf = new QAction("Keep |ki| and |kf| Fixed", this);
	pKeepAbsKiKf->setCheckable(1);
	pKeepAbsKiKf->setChecked(m_sceneRecip.getKeepAbsKiKf());
	m_pMenuViewRecip->addAction(pKeepAbsKiKf);

	m_pBZ = new QAction("Show First Brillouin Zone", this);
	m_pBZ->setIcon(load_icon("res/icons/brillouin.svg"));
	m_pBZ->setCheckable(1);
	m_pBZ->setChecked(bBZVisible);
	m_pMenuViewRecip->addAction(m_pBZ);


	QMenu *pMenuEwald = new QMenu("Ewald Sphere", this);
	QActionGroup *pGroupEwald = new QActionGroup(this);
	m_pEwaldSphereNone = new QAction("Disabled", this);
	m_pEwaldSphereKi = new QAction("Around ki", this);
	m_pEwaldSphereKf = new QAction("Around kf", this);
	for(QAction* pAct : {m_pEwaldSphereNone, m_pEwaldSphereKi, m_pEwaldSphereKf})
	{
		pAct->setCheckable(1);
		pGroupEwald->addAction(pAct);
	}

	m_pEwaldSphereKf->setChecked(1);
	pMenuEwald->addActions(pGroupEwald->actions());
	m_pMenuViewRecip->addMenu(pMenuEwald);


	m_pMenuViewRecip->addSeparator();

	QMenu *pMenuProj = new QMenu("Projection", this);
	pMenuProj->setTearOffEnabled(1);
	QActionGroup *pGroupProj = new QActionGroup(this);

	m_pProjGnom = new QAction("Gnomonic", this);
	m_pProjStereo = new QAction("Stereographic", this);
	m_pProjPara = new QAction("Parallel", this);
	m_pProjPersp = new QAction("Perspectivic", this);

	for(QAction *pAct : {m_pProjGnom, m_pProjStereo, m_pProjPara, m_pProjPersp})
	{
		pAct->setCheckable(1);
		pGroupProj->addAction(pAct);
	}

	m_pProjStereo->setChecked(1);
	pMenuProj->addActions(pGroupProj->actions());

	m_pMenuViewRecip->addMenu(pMenuProj);

#if !defined NO_3D
	QAction *pView3D = new QAction("3D View...", this);
	//pView3D->setIcon(QIcon::fromTheme("applications-graphics"));
	m_pMenuViewRecip->addAction(pView3D);
#endif

	m_pMenuViewRecip->addSeparator();

	QAction *pRecipExport = new QAction("Export Lattice Graphics...", this);
	pRecipExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
	m_pMenuViewRecip->addAction(pRecipExport);

	QAction *pProjExport = new QAction("Export Projection Graphics...", this);
	pProjExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
开发者ID:,项目名称:,代码行数:67,代码来源:

示例3: setTearOffEnabled

void QMenuProto::setTearOffEnabled(bool enabled)
{
  QMenu *item = qscriptvalue_cast<QMenu*>(thisObject());
  if (item)
    item->setTearOffEnabled(enabled);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例4: file


//.........这里部分代码省略.........
    // Einige Aktionen zu einer Gruppe zusammenfassen
    QActionGroup* alignmentGroup = new QActionGroup(
       this );
    alignmentGroup->addAction(leftAlignAct);
    alignmentGroup->addAction(rightAlignAct);
    alignmentGroup->addAction(justifyAct);
    alignmentGroup->addAction(centerAct);
    leftAlignAct->setChecked(true);

    // Nochmals zwei weitere Aktionen
    QAction *InZoom = new QAction(
       tr("&Zoom in ..."), this );
    InZoom->setStatusTip(tr("Zoom in the text"));
    connect( InZoom, SIGNAL(triggered()),
             editor, SLOT(zoomIn() ) );
    QAction *OutZoom = new QAction(
       tr("&Zoom out ..."), this );
    OutZoom->setStatusTip(tr("Zoom out the text"));
    connect( OutZoom, SIGNAL(triggered() ),
             editor, SLOT(zoomOut() ) );

    // Ein Sub-Menü "Format" bei "Bearbeiten" einfügen
    QMenu *formatMenu = workMenu->addMenu(
       tr("&Format") );
    formatMenu->addAction(underLineAct);
    formatMenu->addSeparator();
    formatMenu->addAction(leftAlignAct);
    formatMenu->addAction(rightAlignAct);
    formatMenu->addAction(justifyAct);
    formatMenu->addAction(centerAct);
    formatMenu->addSeparator();
    formatMenu->addAction(InZoom);
    formatMenu->addAction(OutZoom);
    workMenu->setTearOffEnabled(true);
    workMenu->setWindowTitle("Bearbeiten");

    // Zur Demonstration eine Aktion mit QVariant
    Start = new QAction(tr("&Programmstart ..."), this);
    Start->setStatusTip(tr("Zeit des Programmstarts"));
    Start->setData(QVariant(QTime::currentTime()));
    QFont font; font.setBold(true);
    Start->setFont(font);
    Start->setShortcut(tr("Ctrl+T"));
    Start->setShortcutContext(Qt::ApplicationShortcut);
    connect( Start, SIGNAL( triggered() ),
             this, SLOT( printStart() ) );
    workMenu->addAction(Start);


    // Eine neue Statusleiste erzeugen und zum
    // Hauptfenster hinzufügen
    (void*) statusBar ();
    // Permanente Meldung in der Statusleiste
    // Zeichen, Wörter, Zeilen
    sLabel = new QLabel;
    sLabel->setFrameStyle(
       QFrame::Panel | QFrame::Sunken );
    sLabel->setLineWidth(2);
    statusBar()->addPermanentWidget(sLabel);
    connect( editor, SIGNAL( textChanged() ),
             this, SLOT( updateStatusBar() ) );
    updateStatusBar();
    // Laufend aktuelle Uhrzeit in der Statusleiste
    time = new QLCDNumber;
    time->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    time->setLineWidth(2);
开发者ID:rehberry,项目名称:C-C-Programmierung-1,代码行数:67,代码来源:MyWindow.cpp


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