4

I have simple notification application, and I'm using Qt 4.7.1 with C++ to write an application that sits in the system tray. Every time a message comes; I need it to pop-up a window. But, I need it to be rich (i.e., I want to add color and pictures to it). However, all I have is the default pop-up message box. How can I create new richer one that will always pop-up above the tray icon?

mevatron
  • 13,911
  • 4
  • 55
  • 72
user63898
  • 29,839
  • 85
  • 272
  • 514

1 Answers1

5

All the qt widget classes can be styled via stylesheets, depending where create your popup (designer, or in code) assign it a stylesheet with the look that you want it to have. You can test stylesheets in designer by assigning a style to a widget using the context menu of the widget

After further review, the QSystemTrayIcon::showMessage() call puts up a system notification. Which I don't know if it can be styled. The qsystemtrayicon_win.cpp file in the qt distribution shows a workaround and shows a way of how to find the location of the icon in the tray (see QSystemTrayIconSys::findIconGeometry). Once you have the location you could pop up your own window at that location. I did not look to deep, I don't know if you can get to the location for the icon with the information that you have on the public side of Qt. You might have to go all windows with that.

Harald Scheirich
  • 9,676
  • 29
  • 53
  • interesting... I didn't know that popup could be styled. Have u ever managed to do this? – Dr Deo Apr 27 '11 at 13:54
  • 1
    Depends on what class you are talking, there is no QPopup, but QWidget, QFrame, QMenu and so forth can all be styled. I have written an application that does very little custom drawn but uses all the standard components, even QTableView and not look like a Qt App at all – Harald Scheirich Apr 27 '11 at 15:01
  • its not so easy to do this is why im asking , some suggest to inherit and re implement show message again this is not easy or possible – user63898 Apr 28 '11 at 11:45
  • It comes down to how important is it for you to have a private styled popup, is it worth the effort you will have to go through – Harald Scheirich Apr 28 '11 at 12:24
  • funny question,sure i need styled more then styled i need to add more options to it like displaying more then 1 image – user63898 Apr 28 '11 at 18:35