Results 1 to 7 of 7

Thread: dynamic systray icon

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Location
    belgium
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Question dynamic systray icon

    Hi,

    I am trying to paint a systray icon on the fly. My concrete case: I want to reflect the progress of something in the systray icon by drawing a piechart. I could draw into an QImage and set the icon again everytime I update the qimage. However, this does not seem a nice way?
    So I tried subclassing QIcon, overriding the paint method and setting that icon for the systray. However, the paint method is never called (probably because the paint method is not virtual?).
    Then I looked into the QIconEngine stuff, but I am doubtful I am going the right way..

    What would be the correct way to paint an custom/dynamic systemtray icon?

    thanks
    matthias

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: dynamic systray icon

    However, the paint method is never called (probably because the paint method is not virtual?).
    Not probably, but surely there is no paintEvent for a QIcon class !! It isnt derived from QWidget !
    I could draw into an QImage and set the icon again everytime I update the qimage. However, this does not seem a nice way?
    Another way doesnt come to my mind. QSystemTrayIcon is also derived from QObject, so am not sure how the actual painting is done. May be it system dependant.
    Looking into the source code of QSYstrayICon ,,,may be that will give you a hint

  3. #3
    Join Date
    Mar 2006
    Location
    belgium
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: dynamic systray icon

    Not probably, but surely there is no paintEvent for a QIcon class !! It isnt derived from QWidget !
    no, I said "paint" method

    I had looked at QIconEngineV2 but was confused as I didn't see any paint method and QIconEngine is deprecated. Now I realized it is a subclass of QIconEngine, so now it all starts to make sense

  4. #4
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: dynamic systray icon

    Can tell me how did you do this? example code?

  5. #5
    Join Date
    Mar 2006
    Location
    belgium
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: dynamic systray icon

    in the end I just folded
    there does not seem to be a better way (and when you think about it, it makes sense) and since I update the systray only every 60secs anyway, I accepted the overhead

    I did find out that on windows you could send a NIM_MODIFY event using the Shell_NotifyIcon fuction but that requires you to update the HICON anyway. No idea how it works on linux though.

  6. The following user says thank you to mattie for this useful post:

    suseway (10th December 2010)

  7. #6
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: dynamic systray icon

    So can you post the code for Linux?

  8. #7
    Join Date
    Oct 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: dynamic systray icon

    Mattie: sorry, can you post the full code?

Similar Threads

  1. Animated graphical widget in systray. howto?
    By Tetractys in forum Newbie
    Replies: 2
    Last Post: 6th October 2009, 23:51
  2. systray: icon does not display in windows server 2003
    By lovelypp in forum Qt Programming
    Replies: 0
    Last Post: 23rd September 2008, 10:47
  3. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 19:03
  4. How can I get the Systray height ?
    By Nyphel in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2007, 09:04
  5. Difficult:Dynamic Icon size change?!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 10th April 2006, 09:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.