标签:widget for int trigger lse check update menus tap
1.QMenuBar
void MenuBar::initUI() { menuFile= new QMenu("File"); menuFile->addAction("Import"); menuTheme=new QMenu("Theme"); QActionGroup *themeActGroup=new QActionGroup(this); themeDefault=new QAction(ThemeNameType[0]); themeDark=new QAction(ThemeNameType[1]); themeDefault->setCheckable(true); themeDark->setCheckable(true); menuTheme->addAction(themeActGroup->addAction(themeDefault)); menuTheme->addAction(themeActGroup->addAction(themeDark)); themeDefault->setChecked(true); menuSnapshots= new QMenu(this); menuView=new QMenu("View"); menuHelp=new QMenu("Help"); actionTest=menuHelp->addAction("Test"); this->addMenu(menuFile); this->addMenu(menuTheme); this->addMenu(menuView); this->addMenu(menuSnapshots); this->addMenu(menuHelp); connect(this,SIGNAL(triggered(QAction*)),this,SLOT(slotMenu(QAction*))); }
void MenuBar::slotMenu(QAction *act) { if(act->text()=="Import") { importFile(); } else if(act->text()==ThemeNameType[0]) { themeName=ThemeNameType[0]; updateTheme(themeName); } else if(act->text()==ThemeNameType[1]) { themeName=ThemeNameType[1]; updateTheme(themeName); } else if(act->text()=="Test") { emit sigTest(); } }
2.QToolBar
toolBar_=new QToolBar(this); QAction *acts[TOOL_BAR_ACT_COUNT]; acts[0]=new QAction("zoom",this); acts[1]=new QAction("move",this); for(int i=0;i<TOOL_BAR_ACT_COUNT;i++) { acts[i]->setCheckable(true); toolBar_->addAction(acts[i]); } connect(toolBar_,SIGNAL(actionTriggered(QAction*)),this,SLOT(slotToolBar(QAction*)));
void FileDataPlotWidget::slotToolBar(QAction *act) { qDebug()<<"slotToolBar"; if(act->text()=="zoom") { } else if(act->text()=="move") { plot_->setMove(act->isChecked()); qDebug()<<"move"; } }
标签:widget for int trigger lse check update menus tap
原文地址:https://www.cnblogs.com/ike_li/p/12228206.html