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_MAC
void 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);
}
#else
void 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的更多相关文章

  1. How to Restart Qt Application

    How to restart QtApplication As we know, Restarting Application means to exit current application, t ...

  2. WPF 4 Ribbon 开发 之 应用程序菜单(Application Menu)

    原文:WPF 4 Ribbon 开发 之 应用程序菜单(Application Menu)      在上一篇中我们完成了快捷工具栏的开发,本篇将讲解应用程序菜单开发的相关内容.如下图所示,点击程序窗 ...

  3. window当mac用,VirtualBox虚拟机安装os系统

    mac的环境让开发者很享受,既可以像在linux环境下开发,又可以享受到几乎window所有支持的工具软件,比如ide,note,browser 我的安装过程 1.首先你有了64位的window7操作 ...

  4. Window和Mac下端口占用情况及处理方式

    1. 在Mac下端口占用的情况: 找到占用的进程并杀掉: 1.查看端口占用进程 sudo lsof -i :8880 可以看到进程的PID 2.杀掉进程 sudo kill -9 4580(4580为 ...

  5. 如何在window和mac下查找数据库

    1. mac 下终端使用步骤 cd /Applications/xampp/bin ./mysql -u root 2. window CMD命令中执行步骤 D: cd  D:/xampp/mysql ...

  6. Android 环境搭建、基础窗口window/Mac

    1.五步搞定Android开发环境部署--非常详细的Android开发环境搭建教程 2.Android开发学习之路--MAC下Android Studio开发环境搭建 4.Android常用开发工具以 ...

  7. QT获取本机IP和Mac地址

    #include <QNetworkInterface> #include <QList> void MainWindow::getIPPath() { QString str ...

  8. 初识MAC(由window到mac的转变适应)

    * Windows上的软件可以拿到Mac上面安装吗? Windows上面的软件不能拿到Mac的操作系统上安装,除此之外,Windows里的 exe文件,在Mac下面也是无法运行的,要特別注意.如果你要 ...

  9. qt application logging

    “AnalysisPtsDataTool201905.exe”(Win32): 已加载“F:\OpencvProject\ZY-Project\x64\Debug\AnalysisPtsDataToo ...

随机推荐

  1. jenkins轻松玩玩远程windows的进程

    飞测说:在持续集成的路上走了小半年,遇到的一些问题,今天来说一个折腾好几天的问题,和大家交流.我们都知道C#语言开发的,部署站点在IIS上,但是用持续集成的时候,发现经常因为w3wp进程导致文件无法覆 ...

  2. centos 搭建 docker sentry

    1.安装 http://blog.51cto.com/linuxg/2052927 2 .实际调试: 项目: <title>hghh</title> <script sr ...

  3. 记一次git fatal: Unable to find remote helper for 'https'问题的解决

    登陆到远程linux服务器上,使用git, clone的时候报“fatal: Unable to find remote helper for 'https'”错,没管,绕过,使用git clone ...

  4. mac终端下修改MySQL的编码格式--找不到my-default.cnf及my.cnf

    首先请确认正确安装好MySQL. 1- 先配置环境变量path 1.1 打开终端,输入: cd ~ 会进入~文件夹, 1.2 然后输入:touch .bash_profile 回车执行后, 1.3 再 ...

  5. A*专题训练

    POJ2449 Remmarguts' Date UDF's capital consists of N stations. The hall is numbered S, while the sta ...

  6. Jmeter二次开发之代码环境搭建(QQ交流群:577439379)

    一.创建项目 1. 分别下载apache3.1 binaries和source两个压缩包,前者为release版本,后者为jmeter最新的源码,下载地址:http://jmeter.apache.o ...

  7. apache make

    https://jingyan.baidu.com/article/7e4409533d7f0f2fc0e2ef91.html 1. apr apr-util http://archive.apach ...

  8. Accept Job Offer Email Template

    Accept Job Offer Email Template <Date> <Hiring Manager’s name> <Company name> < ...

  9. Java-Runoob-高级教程-实例-字符串:01. Java 实例 – 字符串比较

    ylbtech-Java-Runoob-高级教程-实例-字符串:01. Java 实例 – 字符串比较 1.返回顶部 1. Java 实例 - 字符串比较  Java 实例 以下实例中我们通过字符串函 ...

  10. mysql5.7.12/13在安装新实例时报错:InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero

    .bin/mysqld --initialize-insecure --basedir=xxx --datadir=xxx 然后 .bin/mysqld_safe --defaults-file=xx ...