PDA

View Full Version : Refreshing QAction Text in a QSystemTrayIcon context menu while is showing



choubaka
21st February 2012, 18:51
Hi,

I need to be able to refresh a QAction Text in a QSystemTrayIcon context menu while is showing.
I don't know if it's possible, but it's doesn't seem to be straightforward:

I have a context menu added as a context menu for a QSystemTrayIcon.

Some QAction shows a progress value in their text. A timer check the progress value
and updates the QAction text.

When i click on my systray icon, the QAction text are updated as expected.
But if the menu is showing, the text is not updated. Added or Removed actions
neither.

Any idea?

Thanks!
Choubaka

zepspaiva
29th August 2012, 16:04
Hi,

Nobody answered it and now i'm worried because I'm trying to do the exact same thing. Have you succeeded ?

Thanks!

zepspaiva
29th August 2012, 18:57
Solved! A quick look at the Qt source code helped me! Don't know if it is the best way to do this...

SmartQMenu::UpdateableQMenu(QWidget *parent) :QMenu(parent) {
}

void SmartQMenu::actionUpdate(QAction *action) {
this->actionEvent(new QActionEvent(QActionEvent::ActionChanged, action));
}