本文整理汇总了C++中QMenuBar::show方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::show方法的具体用法?C++ QMenuBar::show怎么用?C++ QMenuBar::show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::show方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSimpleWidget
void tst_WindowsMobile::testSimpleWidget()
{
if (qt_wince_is_smartphone())
QSKIP("This test is only for Windows Mobile", SkipAll);
QMenuBar menubar;
menubar.show();
QWidget maximized;
QPalette pal = maximized.palette();
pal.setColor(QPalette::Background, Qt::red);
maximized.setPalette(pal);
maximized.showMaximized();
QWidget widget;
widget.setGeometry(100, 100, 200, 200);
widget.setWindowTitle("Widget");
widget.show();
qApp->processEvents();
QTest::qWait(1000);
QWidget widget2;
widget2.setGeometry(100, 380, 300, 200);
widget2.setWindowTitle("Widget 2");
widget2.setWindowFlags(Qt::Popup);
widget2.show();
qApp->processEvents();
QTest::qWait(1000);
takeScreenShot("testSimpleWidget_current.png");
compareScreenshots("testSimpleWidget_current.png", ":/testSimpleWidget_current.png");
}
示例2: mouseActivation
void tst_QMenu::mouseActivation()
{
#ifdef Q_OS_WINCE_WM
QSKIP("We have a separate mouseActivation test for Windows mobile.", SkipAll);
#endif
QMenu menu;
menu.addAction("Menu Action");
menu.show();
QTest::mouseClick(&menu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!menu.isVisible());
//context menus can allways be accessed with right click except on windows
menu.show();
QTest::mouseClick(&menu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(!menu.isVisible());
#ifdef Q_OS_WIN
//on windows normal mainwindow menus Can only be accessed with left mouse button
QMenuBar menubar;
QMenu submenu("Menu");
submenu.addAction("action");
QAction *action = menubar.addMenu(&submenu);
menubar.show();
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!submenu.isVisible());
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(submenu.isVisible());
#endif
}
示例3: mouseActivation
void tst_QMenu::mouseActivation()
{
QWidget topLevel;
QMenu menu(&topLevel);
topLevel.show();
menu.addAction("Menu Action");
menu.show();
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
//context menus can always be accessed with right click except on windows
menu.show();
QTest::mouseClick(&menu, Qt::RightButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
#ifdef Q_OS_WIN
//on windows normal mainwindow menus Can only be accessed with left mouse button
QMenuBar menubar;
QMenu submenu("Menu");
submenu.addAction("action");
QAction *action = menubar.addMenu(&submenu);
menubar.show();
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
QVERIFY(!submenu.isVisible());
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::RightButton, 0, QPoint(5, 5), 300);
QVERIFY(submenu.isVisible());
#endif
}
示例4: mouseMoveEvent
void FullscreenSpacerLabel::mouseMoveEvent (QMouseEvent *event)
{
MainWindow *wnd = Core::Instance ().GetReallyMainWindow ();
if (wnd && (wnd->windowState () == Qt::WindowFullScreen))
{
QMenuBar *menu = wnd->findChild<QMenuBar*> ("MenuBar_");
if (!menu)
{
qWarning () << Q_FUNC_INFO
<< "menu is null";
return;
}
QToolBar *toolbar = wnd->findChild<QToolBar*> ("MainToolbar_");
if (!toolbar)
{
qWarning () << Q_FUNC_INFO
<< "toolbar is null";
return;
}
LeechCraft::TabWidget *tabwidget = wnd->GetTabWidget ();
if (!tabwidget)
{
qWarning () << Q_FUNC_INFO
<< "tabwidget is null";
return;
}
QToolBar *bar = Core::Instance ().GetToolBar (tabwidget->currentIndex ());
if (!bar)
{
qWarning () << Q_FUNC_INFO
<< "bar is null";
return;
}
const bool asButton = XmlSettingsManager::Instance ()->property ("ShowMenuBarAsButton").toBool ();
if (event->y () < 5)
{
if (asButton)
menu->hide ();
else if (menu->isHidden ())
menu->show ();
if (toolbar->isHidden ())
toolbar->show ();
if (bar && bar->isHidden ())
bar->show ();
}
else
{
if (!menu->isHidden ())
menu->hide ();
if (!toolbar->isHidden ())
toolbar->hide ();
if (bar && !bar->isHidden ())
bar->hide ();
}
}
}
示例5: on_actionShowMenubar_toggled
void MainWindow::on_actionShowMenubar_toggled(bool enable)
{
QMenuBar *mb = menuBar();
if (enable)
mb->show();
else
mb->hide();
}
示例6: addMenus
void addMenus(QWidget *w){
// QToolBar *tb ;
QMenu *file = new QMenu("Fichier", 0);
QMenuBar *menubar;
menubar = new QMenuBar(w);
QAction *open = new QAction("Ouvrir", 0);
QAction *mode = new QAction("Mode libre", 0);
QAction *quit = new QAction("Quitter", 0);
QAction *stats = new QAction("Historique des scores", 0);
quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
open -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
w->connect(quit, SIGNAL(triggered()), w, SLOT(close()));
w->connect(open, &QAction::triggered, openExplorer);
file->addAction(open);
file->addAction(mode);
file->addAction(stats);
file->addAction(quit);
QMenu*part = new QMenu("Partition", 0);
QAction *elise = new QAction("Lettre à Elise", 0);
QAction *fort = new QAction("Fort Boyard", 0);
QAction *noob = new QAction("Initiation", 0);
w -> connect(elise, &QAction::triggered, setElise);
w -> connect(fort, &QAction::triggered, setBoyard);
w -> connect(noob, &QAction::triggered, setNooby);
part->addAction(elise);
part->addAction(noob);
part->addAction(fort);
menubar->addMenu(file);
menubar->addMenu(part);
menubar->show();
}
示例7: QWidget
FrontView::FrontView(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->listView->setAttribute(Qt::WA_MacShowFocusRect, false);
listModel = new MatrixModel(this);
ui->listView->setModel(listModel);
ui->listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
QMenu *fileMenu = new QMenu("File", this);
auto importFromFileAction = new QAction("Import From...", this);
importFromFileAction->setShortcut(tr("Ctrl+O"));
auto saveToFileAction = new QAction("Save As...", this);
saveToFileAction->setShortcut(tr("Ctrl+S"));
fileMenu->addAction(importFromFileAction);
fileMenu->addAction(saveToFileAction);
QMenuBar *menuBar = new QMenuBar(this);
menuBar->addMenu(fileMenu);
menuBar->show();
connect(ui->addBtn, SIGNAL(clicked()), SLOT(addButtonClicked()));
connect(ui->addToTopBtn, SIGNAL(clicked()), SLOT(addToTopButtonClicked()));
connect(ui->findBtn, SIGNAL(clicked()), SLOT(findBtnClicked()));
connect(saveToFileAction, SIGNAL(triggered()), SLOT(saveToFile()));
connect(importFromFileAction, SIGNAL(triggered()), SLOT(importFromFile()));
connect(ui->listView, SIGNAL(doubleClicked(QModelIndex)),
SLOT(matrixItemDblClicked(QModelIndex)));
}
示例8: run
//.........这里部分代码省略.........
// restore custom key bindings
collection->readSettings();
// Tray menu
menu = new QMenu(i18n("Kaffeine"), this);
action = new QAction(i18n("Play &File"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(open()));
menu->addAction(action);
action = new QAction(i18n("Play &Audio CD"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(openAudioCd()));
menu->addAction(action);
action = new QAction(i18n("Play &Video CD"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(openVideoCd()));
menu->addAction(action);
action = new QAction(i18n("Play &DVD"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(openDvd()));
menu->addAction(action);
#if HAVE_DVB == 1
action = new QAction(i18n("&Watch Digital TV"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(playDvb()));
menu->addAction(action);
#endif
action = new QAction(i18n("&Quit"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(close()));
menu->addAction(action);
// Tray Icon and its menu
QMenu *trayMenu = new QMenu(this);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayMenu);
trayIcon->setIcon(QIcon::fromTheme(QLatin1String("kaffeine"), QIcon(":kaffeine")));
trayIcon->setToolTip(i18n("Kaffeine"));
trayIcon->setContextMenu(menu);
// make sure that the bars are visible (fullscreen -> quit -> restore -> hidden)
menuBar->show();
navigationBar->show();
controlBar->show();
trayIcon->show();
// workaround setAutoSaveSettings() which doesn't accept "IconOnly" as initial state
controlBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
// initialize random number generator
qsrand(QTime(0, 0, 0).msecsTo(QTime::currentTime()));
// initialize dbus objects
QDBusConnection::sessionBus().registerObject(QLatin1String("/"), new MprisRootObject(this),
QDBusConnection::ExportAllContents);
QDBusConnection::sessionBus().registerObject(QLatin1String("/Player"),
new MprisPlayerObject(this, mediaWidget, playlistTab, this),
QDBusConnection::ExportAllContents);
QDBusConnection::sessionBus().registerObject(QLatin1String("/TrackList"),
new MprisTrackListObject(playlistTab, this), QDBusConnection::ExportAllContents);
#if HAVE_DVB == 1
QDBusConnection::sessionBus().registerObject(QLatin1String("/Television"),
new DBusTelevisionObject(dvbTab, this), QDBusConnection::ExportAllContents);
#endif /* HAVE_DVB == 1 */
QDBusConnection::sessionBus().registerService(QLatin1String("org.mpris.kaffeine"));
show();
// set display mode
switch (Configuration::instance()->getStartupDisplayMode()) {
case Configuration::StartupNormalMode:
// nothing to do
break;
case Configuration::StartupMinimalMode:
mediaWidget->setDisplayMode(MediaWidget::MinimalMode);
break;
case Configuration::StartupFullScreenMode:
mediaWidget->setDisplayMode(MediaWidget::FullScreenMode);
break;
case Configuration::StartupRememberLastSetting: {
int value = KSharedConfig::openConfig()->group("MainWindow").readEntry("DisplayMode", 0);
switch (value) {
case 0:
// nothing to do
break;
case 1:
mediaWidget->setDisplayMode(MediaWidget::MinimalMode);
break;
case 2:
mediaWidget->setDisplayMode(MediaWidget::FullScreenMode);
break;
}
break;
}
}
parseArgs();
}