Results 1 to 8 of 8

Thread: Constructing tray icon with QIcon

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Constructing tray icon with QIcon

    Hello,

    I have made tray icon with QSystemTrayIcon.
    I use following to set icon of trayicon (I use qrc resources):

    trayicon->setIcon(QIcon(":/ikona/sending.gif"));

    On my computer icon is constructed ok, but when deployed on another computer, I get empty icon - tray icon with no picture in it. How is this possible - I thought that Qt resources are compiled into binary and because of that always available when deployed to another computer? Any idea, what is wrong here?

  2. #2
    Join Date
    May 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Constructing tray icon with QIcon

    try this:

    trayIcon = new QSystemTrayIcon(this);
    icon.addPixmap(QPixmap(QString::fromUtf8(":/mailbox.png")), QIcon::Normal, QIcon::Off);
    trayIcon->setIcon(icon);

    for this you need to add the image file name into your qrc file also don't forget to copy the image file while moving to other system.


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

    Default Re: Constructing tray icon with QIcon

    It could also be a problem of image plugin.
    copy the proper dll from QTDIR\plugins\imageformats to your destination and see if it works

  4. The following user says thank you to aamer4yu for this useful post:

    Tiansen (6th October 2009)

  5. #4
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Constructing tray icon with QIcon

    Thanks for suggestions, I converted gif to png, and now it works! Excellent!

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

    Default Re: Constructing tray icon with QIcon

    I converted gif to png, and now it works!
    Then surely it must be a case of missing image plugin dll. Try my last post and see if it works for gif ?
    Also is ur qt built with gif support ?

  7. #6
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Constructing tray icon with QIcon

    I am not sure if I've done it right. I copied qgif4.dll into plugins\imageformats subfolder of where my exe is deployed.
    It still does not work with gif.
    I am using prebuilt Qt binaries that came with 2009.03.

  8. #7
    Join Date
    Oct 2009
    Location
    Rennes, France
    Posts
    20
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Constructing tray icon with QIcon

    Hi
    Quote Originally Posted by Tiansen View Post
    I am not sure if I've done it right. I copied qgif4.dll into plugins\imageformats subfolder of where my exe is deployed.
    you must copy this dll into imageformats subfolder of where your exe is deployed and not plugins\imageformats
    Contributor from the French Qt community from developpez.com
    * Forum
    * FAQ Qt ( > 100 QR)
    * Advanced and Beginner Tutorials

  9. The following user says thank you to yan for this useful post:

    Tiansen (7th October 2009)

  10. #8
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Constructing tray icon with QIcon

    Yes and now it works with gif too!!! Thanks!

Similar Threads

  1. Tray icon is missing on some systems.
    By eurodatar in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2011, 00:39
  2. How to write some text next to the system tray icon?
    By alex chpenst in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2008, 08:43
  3. possible to convert string/numbers to tray icon?
    By jarmok in forum Qt Programming
    Replies: 2
    Last Post: 19th July 2008, 18:34
  4. Replies: 4
    Last Post: 30th June 2008, 06:25
  5. Make error with Qt Jambi 4.3.2_01
    By pamalite in forum Installation and Deployment
    Replies: 0
    Last Post: 22nd November 2007, 12:05

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.