本文整理汇总了C++中QMenuBar::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::clear方法的具体用法?C++ QMenuBar::clear怎么用?C++ QMenuBar::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDocumentFileMenu
/**
* <p>Adjust the "File" menu and toolbar contents as appropriate for the
* document screen. Sets the "File" menu to have the following content:</p>
* <ul>
* <li>Save</li>
* <li>(items added using addToFileMenu() go here)</li>
* <li><i>(separator)</i></li>
* <li>Close</li>
* <li>Preferences</li>
* <li><i>(separator)</i></li>
* <li>Quit</li>
* </ul>
* <p>Also shows the "Save" button on the toolbar. If creating
* a new file which isn't automatically saved, follow this with a call
* to setEdited(true). On the Mac, also shows a document icon in the
* titlebar. This method should be called after the visibility of any
* application-specific actions has been updated (due to a Maemo
* implementation detail).</p>
*/
void QQMenuHelper::updateDocumentFileMenu()
{
// update action visibility
fileSaveAction->setVisible(true);
fileSeparatorAction->setVisible(true);
closeAction->setVisible(true);
fileNewAction->setVisible(false);
fileOpenAction->setVisible(false);
recent->menuAction()->setVisible(false);
// enable and disable actions as appropriate for the current state
fileNewAction->setEnabled(false);
fileOpenAction->setEnabled(false);
fileSaveAction->setEnabled(false);
closeAction->setEnabled(true);
#if defined(Q_WS_HILDON) || defined(Q_WS_MAEMO_5)
QMenuBar *mb = mainWindow->menuBar();
mb->clear();
int count = extraFileActions.count();
for (int i = 0; i < count; i++) {
if (extraFileActions[i]->isVisible()) {
mb->addAction(extraFileActions[i]);
}
}
mb->addAction(prefsAction);
mb->addAction(helpAction);
#endif
#if defined(Q_WS_MAC)
mainWindow->setWindowIcon(docIcon);
#endif
}
示例2: mainwindow
void
qt_tm_widget_rep::install_main_menu () {
if (main_menu_widget == waiting_main_menu_widget) return;
main_menu_widget = waiting_main_menu_widget;
QList<QAction*>* src = main_menu_widget->get_qactionlist();
if (!src) return;
QMenuBar* dest = mainwindow()->menuBar();
dest->clear();
for (int i = 0; i < src->count(); i++) {
QAction* a = (*src)[i];
if (a->menu()) {
//TRICK: Mac native QMenuBar accepts only menus which are already populated
// this will cause a problem for us, since menus are lazy and populated only after triggering
// this is the reason we add a dummy action before inserting the menu
a->menu()->addAction("native menubar trick");
dest->addAction(a->menu()->menuAction());
QObject::connect (a->menu(), SIGNAL (aboutToShow()),
the_gui->gui_helper, SLOT (aboutToShowMainMenu()));
QObject::connect (a->menu(), SIGNAL (aboutToHide()),
the_gui->gui_helper, SLOT (aboutToHideMainMenu()));
}
}
}