Qt Application Menu In Window and Mac

來源:互聯網
上載者:User

標籤:OLE   def   play   video   cte   sig   mac   end   set   

Application Menu

Application menu in different operator systems has different designed style. like Windows and Mac os, they are different.In the code, we can use different Macro ,eg:Q_OS_MAC and Q_OS_WIN

#ifdef Q_OS_MACvoid MainWindow::InitMenu(){    QMenuBar* mBar = menuBar();    QMenu* mApp   = new QMenu(tr("App"),this);    QMenu* mFile  = new QMenu(tr("&File"),this);    mBar->addMenu(mApp);    mBar->addMenu(mFile);    /** In Mac,We should to set action role */    QAction* actAbout = new QAction(tr("&About"),this);    actAbout->setMenuRole(QAction::AboutRole);    QAction* actSetApp = new QAction(tr("&Preference..."),this);    actSetApp->setMenuRole(QAction::PreferencesRole);    mApp->addAction(actAbout);    mApp->addAction(actSetApp);    QAction* actOpen = new QAction(tr("&Open Video Files..."),this);    mFile->addAction(actOpen);    connect(actOpen,&QAction::triggered,_player,&Player::StOpen);    connect(actSetApp,&QAction::triggered,this,&MainWindow::StShowSetDlg);}#elsevoid MainWindow::InitMenu(){    QMenuBar* mBar = menuBar();    QMenu* mFile  = new QMenu(tr("&File"),this);    QMenu* mSet   = new QMenu(tr("&Setting"),this);    QMenu* mAbout = new QMenu(tr("&About"),this);    QAction* actOpen = new QAction(tr("&Open Video Files..."),this);    QAction* actExit = new QAction(tr("&Exit out"),this);    mFile->addAction(actOpen);    mFile->addSeparator();    mFile->addAction(actExit);    QAction* actSetApp = new QAction(tr("&Setting App..."),this);    mSet->addAction(actSetApp);    mBar->addMenu(mFile);    mBar->addMenu(mSet);    mBar->addMenu(mAbout);    connect(actOpen,&QAction::triggered,_player,&Player::StOpen);    connect(actExit,&QAction::triggered,this,[=](){close();});    connect(actSetApp,&QAction::triggered,this,&MainWindow::StShowSetDlg);}#endif

Qt Application Menu In Window and Mac

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.