以前用过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()));