qt工具栏和菜单栏

以前用过qt,但是老是忘,得现查。现记录如下

1,一个menubar可以有多个menu

2,一个menu可以有多个action,菜单栏里的各项叫做action,而不是Menu,action可以当作实体,

3,每个action对应事件


比如

1,一个menubar可以有多个menu
 QMenu * theMenu1 = new QMenu(this);
 QMenu * theMenu2 = new QMenu(this);
 QMenu * theMenu3 = new QMenu(this);
 QMenu * theMenu4 = new QMenu(this);
 QMenu * theMenu5 = new QMenu(this);
 QMenu * theMenu6 = new QMenu(this);
 menuBar()->addMenu(theMenu1)->setText("tif and pcl");
 menuBar()->addMenu(theMenu2)->setText("tif and pcl");
 menuBar()->addMenu(theMenu3)->setText("tif and pcl");
 menuBar()->addMenu(theMenu4)->setText("tif and pcl");
 menuBar()->addMenu(theMenu5)->setText("tif and pcl");
 menuBar()->addMenu(theMenu6)->setText("tif and pcl");


2,一个menu可以有多个action
 QAction * theAction1 = new QAction("pcltotif", this);
 QAction * theAction2 = new QAction("pcltotif", this);
 QAction * theAction3 = new QAction("pcltotif", this);
 QAction * theAction4= new QAction("pcltotif", this);
 QAction * theAction5 = new QAction("pcltotif", this);
 QAction * theAction6 = new QAction("pcltotif", this);
 theMenu->addAction(theAction1);

 theMenu->addAction(theAction2);

 theMenu->addAction(theAction3);

 theMenu->addAction(theAction4); 

theMenu->addAction(theAction5); 

theMenu->addAction(theAction6);

3每个action可以对应一个触发事件


 connect(theAction, SIGNAL(triggered()) , this, SLOT(showDialogPCLtoTif()));


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值