Question

There are similar questions to this one but they didn't solve my problem.

I just have a simple MainWindow class which shows up on start. The constructor contains this code :

QWidget* centralWidget = new QWidget(this);
this->setCentralWidget( centralWidget );

QSystemTrayIcon a;
a.setIcon( QIcon::fromTheme("edit-undo") );
a.setVisible( true );
a.show();
a.showMessage( tr( "Title" ), tr( "Message - Test" ) );

It's just a window with a centralWidget for later. I just wanted to test the QSystemTrayIcon but it does not show. The Icon is 100% correct, so it's not the problem.

Anyone knows what's wrong? I am on a Linux system (Ubuntu 12.04).

Était-ce utile?

La solution

QSystemTrayIcon is not a pointer.

Therefore, it gets destroyed as soon as you leave the body of the constructor.

Solution: make a private pointer member of your class, and handle its destruction properly upon exit.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top