Query regarding aboutToShow signal of Qmenu widget.
-
@Ratzz But that action will displayed as drop down of About. I don't want that I just when I click About it should display the dialog box irrespective if we click other menu items.
-
But that action will displayed as drop down of About.
Not sure what you have done & indented to do. If your intent is to show the dialog when you click on about action, as @Ratzz suggested, you can add three different actions & connection to slot. Inside the slot you can show any dialog you want. If not show the image of what you are planning to achieve.
-
@dheerendra I mean if I add action in About it will show context menu when I click on About.
Suppose I added Action About1 in About then when I click About it will show About1 as context Menu option. as per my understanding?If not please let me know how can I add action and it should be not visible in UI and just clickin on About it will show dialog...how can i do this through programming
-
Add this in construction.
connect(ui->aboutAction,&QAction::triggered, this,&MyWidget::showAbout)MyWidget::showAbout() {
// Create any dialog
// show it
}You can connect signal/slot from Designer also. I'm showing you example from code.
-
@dheerendra I am using design view. And I do not want that action to be displayed in menu. Where and how should i create the action and attach to the about menu.
-
How are you adding the about menu option ? Can you tell ?
-
@Ratzz But that action will displayed as drop down of About. I don't want that I just when I click About it should display the dialog box irrespective if we click other menu items.
@Ayush-Gupta said in Query regarding aboutToShow signal of Qmenu widget.:
when I click About it should display the dialog box irrespective if we click other menu items.
U can create an
QAction
to the menubar directly.
Your About menu will always be the last menu . Just try to add from code and connect toaboutclick()
-
@dheerendra I am adding through design view of QT.
@Ratzz Can I add QAction to the About menu using progamming even I if i am using design view
-
@dheerendra I am adding through design view of QT.
@Ratzz Can I add QAction to the About menu using progamming even I if i am using design view
@Ayush-Gupta said in Query regarding aboutToShow signal of Qmenu widget.:
Can I add QAction to the About menu using progamming even I if i am using design view
I think u can do in two ways
1)Using CodeQMenuBar *m = this->menuBar(); QAction *aboutMenu = new QAction("About"); connect(aboutMenu, &QAction::triggered, this, &MainWindow::aboutclick); m->addAction(aboutMenu);
- Using designer- Add an menu then connect to your slot
connect(ui->menuAbout,&QMenu::aboutToShow,this,&MainWindow::aboutclick);
-
Can I add QAction to the About menu using progamming even I if i am using design view
You can do it. That is the code I wrote and showed you.