Results 1 to 20 of 38

Thread: Images/icons. It's not displayed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    ok, thanks, know it's cleare for me.
    and one more question - can I display on my form animated gif? When I add some pictures, the supported format is jpg and some others (I suggest), so within designer I can't add gif..

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images/icons. It's not displayed

    You have to enable gif support and recompile Qt. But it's not enough to make animated gifs work. You have to use QMovie.

  3. #3
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    ok, with animations i'll "play" later

    know, I tried to use resources, as you said...
    .qrc file:
    Qt Code:
    1. <!DOCTYPE RCC><RCC version="1.0">
    2. <qresource>
    3. <file>images/icon.jpg</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 
    In my .pro I added RESOURCES = res.qrc .
    And finally, in my constructor i put down
    Qt Code:
    1. this->setWindowIcon(QIcon(":/images/icon.jpg"));
    To copy to clipboard, switch view to plain text mode 
    No result..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images/icons. It's not displayed

    Is the path correct during compilation (debug/release folder issues again)? What does QFile::exists(":/images/icon.jpg") return?

  5. #5
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    well, QFile::exists() return true. What about the path, tutorial says that
    The specified paths are relative to the directory containing the .qrc file.
    And nothing about debug/release folders path..

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images/icons. It's not displayed

    What happens if you try to display a PNG file instead of a JPEG? And please test on a QLabel and not using a window icon.

  7. #7
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    No result... I add to /images an png image - image.png
    To res.qrc I add -
    Qt Code:
    1. <file>images/image.png</file>
    To copy to clipboard, switch view to plain text mode 
    And my .cpp:
    Qt Code:
    1. qSpeed->setWindowIcon(QIcon(":/images/image.png"));
    To copy to clipboard, switch view to plain text mode 
    //qSpeed is a label

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Images/icons. It's not displayed

    Have you recompiled your resource?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images/icons. It's not displayed

    First of all, did you run qmake after adding the resource file to the project?

  10. #10
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    marcel, wysota:
    sure

    But, can I put my icon on a label, by using QLabel::setWindowIcon(QIcon(...)) ? Maybe this is the problem?...

  11. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Images/icons. It's not displayed

    No.
    Use QLabel::setPixmap.

  12. #12
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Images/icons. It's not displayed

    Qt Code:
    1. qSpeed->setPixmap(QPixmap(":/images/image.png"));
    To copy to clipboard, switch view to plain text mode 
    no result.....:-\

Similar Threads

  1. Replies: 20
    Last Post: 15th August 2008, 23:19
  2. JPEG Image isn't displayed!?
    By GodOfWar in forum Qt Programming
    Replies: 9
    Last Post: 16th April 2007, 15:01
  3. QLineEdit - Float number not displayed correct
    By morty in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2006, 00:47
  4. Replies: 6
    Last Post: 10th April 2006, 10:47

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.