How do I connect an action responding to a menu bar item?
-
wrote on 5 Mar 2024, 12:02 last edited by
I am lost here...
I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??Regards,
Juan Dent -
I am lost here...
I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??Regards,
Juan Dentwrote on 5 Mar 2024, 12:08 last edited by Pl45m4 3 May 2024, 12:15@jdent said in How do I connect an action responding to a menu bar item?:
I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??
connect(ui->yourMenuAction, &QAction::triggered, this, &MainWindow::yourFunction);
For the first parameter, use the
ui
pointer to access objects in your generated form class... then pick the object name of the item you want to use.
All access to objects created in Designer works likeui->objectname
(you find the name in QtDesigner's object inspector list)Read more about
Signals & Slots
here: -
@jdent said in How do I connect an action responding to a menu bar item?:
I created a menu in Qt Designer, but how do I implement the connection to the function I want called ??
connect(ui->yourMenuAction, &QAction::triggered, this, &MainWindow::yourFunction);
For the first parameter, use the
ui
pointer to access objects in your generated form class... then pick the object name of the item you want to use.
All access to objects created in Designer works likeui->objectname
(you find the name in QtDesigner's object inspector list)Read more about
Signals & Slots
here: -
3/3