Results 1 to 3 of 3

Thread: icon

  1. #1
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default icon

    Hi,

    I want to display an icon on a button. I added a prefix and the correspondent .png file to the project. Then I used the following syntax:

    OKbutton->setIcon(QIcon(":/GraphicBarrier/Headphones-32.png"));

    The code compiles but NO icon is displayed. Why is this happening?

    Thank you

  2. #2
    Join Date
    Jul 2010
    Location
    Poland
    Posts
    184
    Thanks
    70
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: icon

    I had the same problem. If You are using QT Creator try to create resource file, and then use it like that:
    Qt Code:
    1. myButton->setIcon(QIcon(":/_YOUR_PREFIX_/icon.png"));
    To copy to clipboard, switch view to plain text mode 

    best regards
    Tomasz

  3. The following user says thank you to Tomasz for this useful post:

    Maluko_Da_Tola (26th August 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanks
    35
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: icon

    Thanks very much

Similar Threads

  1. Replies: 0
    Last Post: 17th March 2010, 13:25
  2. Replies: 2
    Last Post: 12th October 2008, 14:42
  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. Replies: 1
    Last Post: 17th January 2008, 10:17
  5. how to set icon for exe?
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 22:54

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.