本文整理汇总了C++中QMenuBar::setNativeMenuBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QMenuBar::setNativeMenuBar方法的具体用法?C++ QMenuBar::setNativeMenuBar怎么用?C++ QMenuBar::setNativeMenuBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMenuBar
的用法示例。
在下文中一共展示了QMenuBar::setNativeMenuBar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostWindowCreate
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate()
{
// very bad hack...
berry::IWorkbenchWindow::Pointer window =
this->GetWindowConfigurer()->GetWindow();
QMainWindow* mainWindow =
qobject_cast<QMainWindow*> (window->GetShell()->GetControl());
if (!windowIcon.isEmpty())
{
mainWindow->setWindowIcon(QIcon(windowIcon));
}
mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);
/*mainWindow->setStyleSheet("color: white;"
"background-color: #808080;"
"selection-color: #659EC7;"
"selection-background-color: #808080;"
" QMenuBar {"
"background-color: #808080; }");*/
// Load selected icon theme
QStringList searchPaths = QIcon::themeSearchPaths();
searchPaths.push_front( QString(":/org_mitk_icons/icons/") );
QIcon::setThemeSearchPaths( searchPaths );
berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE);
QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>");
if( iconTheme == QString( "<<default>>" ) )
{
iconTheme = QString( "tango" );
}
QIcon::setThemeName( iconTheme );
// ==== Application menu ============================
QMenuBar* menuBar = mainWindow->menuBar();
menuBar->setContextMenuPolicy(Qt::PreventContextMenu);
#ifdef __APPLE__
menuBar->setNativeMenuBar(true);
#else
menuBar->setNativeMenuBar(false);
#endif
QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window);
fileOpenAction->setShortcut(QKeySequence::Open);
QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window);
fileSaveAction->setShortcut(QKeySequence::Save);
fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg")));
closeProjectAction = new QmitkCloseProjectAction(window);
closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg")));
auto perspGroup = new QActionGroup(menuBar);
std::map<QString, berry::IViewDescriptor::Pointer> VDMap;
// sort elements (converting vector to map...)
QList<berry::IViewDescriptor::Pointer>::const_iterator iter;
berry::IViewRegistry* viewRegistry =
berry::PlatformUI::GetWorkbench()->GetViewRegistry();
const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews();
bool skip = false;
for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
{
// if viewExcludeList is set, it contains the id-strings of view, which
// should not appear as an menu-entry in the menu
if (viewExcludeList.size() > 0)
{
for (int i=0; i<viewExcludeList.size(); i++)
{
if (viewExcludeList.at(i) == (*iter)->GetId())
{
skip = true;
break;
}
}
if (skip)
{
skip = false;
continue;
}
}
if ((*iter)->GetId() == "org.blueberry.ui.internal.introview")
continue;
if ((*iter)->GetId() == "org.mitk.views.imagenavigator")
continue;
if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview")
continue;
std::pair<QString, berry::IViewDescriptor::Pointer> p(
(*iter)->GetLabel(), (*iter));
VDMap.insert(p);
}
//.........这里部分代码省略.........