I am making a QT GUI based application for demonstration of some algorithms, I want to select one algorithm at a time from menu bar.
for this I have two approaches in mind,
one is to make QAction checkable and loop through each and check only one which is clicked and uncheck all the others.
the other is to add radio button in menubar.
which approach is more better ?
If second one is better how do I do that ?
In most main window style applications you would use the menuBar() function provided in QMainWindow, adding QMenus to the menu bar and adding QActions to the pop-up menus. Example (from the Menus example): fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(newAct);
You can use QActionGroup and use setExclusive(true)
which will allow only one checkable QAction
to be checked at a time, so you don't have to do it manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With