[Solved]how to add combo box in trayicon menu?
-
How about having checkable (possibly exclusive) menu options instead?
-
Can I add radio button in tray menu? Because otu of those option user can select at a time only one.
-
Yes, you can. See [[doc:QActionGroup]].
-
Thanks Andre,
I have successfully able to create QActionGroup But how to add it into Qmenu that is not given any where in the link given by you. could you please help me to find out how to add QActionGroup into Qmenu?Thanks in advance. :)
-
Hey,
I am able to add
but somehow leftAlignAct->setChecked(true); not working for me. I am not able to marked as checked any action in the group. -
Adding should work like this:
@
myMenu->addActions(theActionGroup->actions());
@On the not being able to mark an item as checked: could you show some code please? The code you show is from the example on the QActionGroup page.
-
I am working on a updater module which will be having a tray menu. Below is the code piece I am working on.
@
........
Once1DayAction = new QAction(tr("Once in every day."), this);
connect(Once1DayAction, SIGNAL(triggered()), this, SLOT(UpdateGroupActs()));Once7DayAction = new QAction(tr("Once in 7 days."), this); connect(Once7DayAction, SIGNAL(triggered()), this, SLOT(UpdateGroupActs())); Once7DayAction->setChecked(true); alignmentGroup = new QActionGroup(this); alignmentGroup->addAction(Once1DayAction); alignmentGroup->addAction(Once7DayAction); // create tray icon menu trayIconMenu = new QMenu(this); trayIconMenu->addSeparator()->setText(tr("Updates")); // Separater is visible but Text is not visible in the menu. trayIconMenu->addActions(alignmentGroup->actions()); trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu);
........
@Note: I tried to use "checkedAction" to see whether any thing is checked but it is returning NULL, seems nothing is set.
-
For some reason you must call setCheckable(true) on the actions to become checkable.
-
Hi Volker,
I tried both setChecked(true) and setCheckable(true) but none of them help. Not sure what is causing this problem. Please let me know if you have any clue. -
I don't have any further ideas now. It did not work for me without calling setCheckable at first. After adding that, I could check the menu entries.
Which OS are you using?
-
Thanks Every one thanks for your support and petience. It is working now. I had to use both in particular order.