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. ubuntu 11.04 Gnome 恢复默认的任务栏面板

    在Ubuntu(实际是GNOME) 中,桌面上默认的任务栏菜单面板是上下两栏,上面(Panel) 是系统菜单和通知区域下面是窗口存放切换区域,那么作为ubuntu用户来说,你总会使系统用起来更顺手更美 ...

  2. BZOJ5312: 冒险【线段树】【位运算】

    Description Kaiser终于成为冒险协会的一员,这次冒险协会派他去冒险,他来到一处古墓,却被大门上的守护神挡住了去路,守护神给出了一个问题, 只有答对了问题才能进入,守护神给出了一个自然数 ...

  3. Ambiguous reference to member 'dataTask(with:completionHandle:)'错误

    在研究IOS的网络请求过程中,因为NSURLConnection已经过时,需要引用到URLSession var url:NSURL=NSURL(string: "http://3g.163 ...

  4. linux 下mongodb 3.2.5单机版安装

    mongodb3.0.x的安装教程网上很多,这里主要介绍3.2.5的安装 linux iso 在\\10.10.10.1\ShareDoc\User\yipengzhi\ISO\Centos7.0   ...

  5. PDO exec 执行时出错后如果修改数据会被还原?

    PDO exec 执行时出错后如果修改数据会被还原? 现象 FastAdmin 更新了 1127 版本,但是使用在线安装方式出现无法修改管理员密码的问题. 一直是默认的 admin 123456 密码 ...

  6. 洛谷3343(ZJOI2015)地震后的幻想乡

    题目:https://www.luogu.org/problemnew/show/P3343 1.那个时间与边的大小排名有关,所以需要求一下最大边的期望排名就行. 2.期望排名是这样算的:(排名为1的 ...

  7. Centos 6 安装 配置 oracle11g R2

    1.安装centos6.3_64位: 下载地址:http://mirror.bit.edu.cn/centos/6.3/isos/x86_64/ CentOS-6.3-x86_64-bin-DVD1. ...

  8. C# 实现快速闪电关机、快速重启

    using System; using System.Runtime.InteropServices; namespace FastReboot { static class Program { pr ...

  9. 智能家居入门DIY——【五、执行命令】

    前面几篇介绍了ESP8266使用AT命令来连接WIFI实现一系列功能.这一篇介绍一下使用Wemos D1 Wifi来进行开发,当然也可以用常见的8针ESP8266来完成(只是需要按网上的方法将Ardu ...

  10. Ant+jmeter 实现自动化性能测试

    一.前言 性能测试首选的工具是JMeter,在此不多做介绍,但是不得不说JMeter也是一款非常好的接口测试工具.性能测试过程中手工重复的活动非常多,为了给客户提供一个性能测试报告,我用了一周时间进行 ...