1、右键菜单。
这个其实用QT实现容易过头了,不过其中还是被卡了一下,就是给右键菜单选项前面打钩那个功能,首先是不知道该怎么形容,怎么搜都搜不到,后来去慢慢研究帮助文档,总算是弄出来了。
首先才创建菜单项和添加项,然后绑定槽
act_about = new QAction(tr("关于"), this);
act_autoRun = new QAction(tr("开机启动"), this);
act_autoRun->setCheckable(true);//设置可选
act_autoRun->setChecked(bAutoRun);//设置是否选中
act_exit = new QAction(tr("退出"), this);
menu=new QMenu(this);
menu->addAction(act_about); //添加菜单项1
menu->addAction(act_autoRun);
menu->addAction(act_exit); //添加菜单项2
connect(menu, SIGNAL(aboutToHide()), this, SLOT(AboutToHide()));
connect(menu, SIGNAL(aboutToShow()), this, SLOT(AboutToShow()));
connect(act_exit, SIGNAL(triggered()), this, SLOT(close()));
connect(act_exit, SIGNAL(triggered()), this, SLOT(Close()));
connect(act_about, SIGNAL(triggered()), this, SLOT(About()));
connect(act_autoRun, SIGNAL(toggled (bool)), this, SLOT(Check(bool)));
目前只有三个项:关于、开机启动、退出。