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


C++ QMenuBar::clear方法代码示例

本文整理汇总了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
}
开发者ID:jmbowman,项目名称:portabase,代码行数:52,代码来源:qqmenuhelper.cpp

示例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()));
    }
  }
}
开发者ID:KarlHegbloom,项目名称:texmacs,代码行数:23,代码来源:qt_tm_widget.cpp


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