Results 1 to 5 of 5

Thread: QToolButton icon did not appear

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question QToolButton icon did not appear

    hi,
    i am using QToolButton to QFileDialog::getOpenFileName so i
    used the following function to set the button icon
    Qt Code:
    1. browseButton->setIcon(QIcon(":/images/open.png"));
    To copy to clipboard, switch view to plain text mode 
    and i added the file entry in the resource file
    Qt Code:
    1. <file>images/open.png</file>
    To copy to clipboard, switch view to plain text mode 
    but, the icon did not appear
    what should i do?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolButton icon did not appear

    Is ":/images/open.png" listed when you do:
    Qt Code:
    1. QDirIterator it(":", QDirIterator::Subdirectories);
    2. while (it.hasNext())
    3. qDebug() << it.next();
    To copy to clipboard, switch view to plain text mode 
    ?
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolButton icon did not appear

    thank you i did it and i found that the directories listed was
    :/dialog/images/open.png
    so i added /dialog to the
    QToolButton::setIcon
    and it works fine
    but why the /dialog added however there is no directory called dialog in my project?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolButton icon did not appear

    Notice the prefix-attribute of qresource-element:
    Qt Code:
    1. <qresource prefix="/dialog">
    2. ...
    3. <file>images/open.png</file>
    4. ...
    5. </qresource>
    To copy to clipboard, switch view to plain text mode 
    Does your resource file look like this?
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    mismael85 (24th March 2008)

  6. #5
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolButton icon did not appear

    exactly , so i deleted the (prefix="/dialog") from my resource file and every thing works fine now .
    thank you.

Similar Threads

  1. Retrieving a file's icon
    By sbeltz in forum Qt Programming
    Replies: 8
    Last Post: 10th September 2008, 12:35
  2. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 19:03
  3. QToolButton and Style sheet
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 1st December 2007, 08:38
  4. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 10:23
  5. QSystemTrayIcon doesn't show icon ?
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 25th January 2007, 19:17

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.