Results 1 to 3 of 3

Thread: App cannot load resource images - why?

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question App cannot load resource images - why?

    I am working on QML app and here is project structure:
    projectStructure.jpg
    As you can see, in I have resource file ueicons.qrc, which contains icons, used in app. I tried to add icons with:
    Qt Code:
    1. import QtQuick 2.4
    2. import QtQuick.Controls 1.3
    3. import QtQuick.Window 2.2
    4. import QtQuick.Dialogs 1.2
    5. import QtMultimedia 5.0
    6. import QtQuick.Layouts 1.0
    7. import QtTest 1.1
    8.  
    9. import "gui/windows"
    10. import "gui/items"
    11.  
    12. ApplicationWindow
    13. {
    14. id: ueWindowMain
    15.  
    16. title: qsTr("testapp")
    17.  
    18. width: Screen.desktopAvailableWidth
    19. height: Screen.desktopAvailableWidth
    20.  
    21. visible: true
    22.  
    23. opacity: 1.0
    24.  
    25. contentOrientation: Qt.LandscapeOrientation
    26.  
    27. color: "black"
    28.  
    29. UeKeypad
    30. {
    31. id: ueLoginKeypad
    32. } // ueLoginKeypad
    33.  
    34. StatusBar
    35. {
    36. id: ueStatusBar
    37.  
    38. RowLayout
    39. {
    40. spacing: 8
    41.  
    42. UeStatusIndicator
    43. {
    44. id: ueStatusIndicatorDatabaseConnected
    45.  
    46. ueParamImageStatusOn: "qrc:///ueIcons/ueDbConnectionOk.png"
    47. ueParamImageStatusOff: "qrc:///ueIcons/ueDbConnectionError.png"
    48. } // ueStatusIndicatorDatabaseConnected
    49. } // RowLayout
    50. } // ueStatusBar
    51. } // ueWindowMain
    To copy to clipboard, switch view to plain text mode 
    And when I run this app, I get following QML error:
    QML Image: Cannot open: qrc:///ueIcons/ueDbConnectionError.png
    Why?
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: App cannot load resource images - why?

    If you have C++ code, you could create a QDir on ":/ueIcons", check if it exists, is a directory and entryList() returns the values.

    Or use a GammaRay to do runtime inspection of the actual application.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: App cannot load resource images - why?

    AFAICT, the path to the icon is:
    Qt Code:
    1. qrc:///ueIcons/icons/ueDbConnectionOk.png
    To copy to clipboard, switch view to plain text mode 

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

    MarkoSan (14th September 2015)

Similar Threads

  1. GIF images in qt resource file
    By A9am in forum Newbie
    Replies: 3
    Last Post: 25th November 2013, 10:36
  2. How to load icons from resource file
    By joseph in forum Qt Programming
    Replies: 7
    Last Post: 25th June 2012, 08:00
  3. How to add 50 MB of images to resource file ??????
    By prajnaranjan.das in forum Newbie
    Replies: 5
    Last Post: 24th December 2010, 05:56
  4. Replies: 1
    Last Post: 16th November 2010, 18:45
  5. problem about load resource file dynamically
    By Raul in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2010, 06:56

Tags for this Thread

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.