Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. (resource) images not displaying
Forum Updated to NodeBB v4.3 + New Features

(resource) images not displaying

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 459 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    I'm trying to use the resource system to include several small images. I've created and populated a .qrc file like so:
    icons.PNG
    And in one of my .qml files, I have this:

        Image {
            source: ":/icons/Home.png"
        }
    

    I don't get a runtime error, but my image doesn't display. I'm sure I'm leaving a step out of using the resource system. Can anyone tell me what I've missed?

    Qt 6.4, cmake project.

    Thanks...

    EDIT: I also added icons.qrc to my CMakeLists.txt file:

    qt_add_executable(
        appnga
        main.cpp
        icons.qrc
        resources.qrc
        clock.cpp
        clock.h
    )
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      You probably need to add the following to your CMakeLists.txt file:

      set(CMAKE_AUTORCC ON)
      
      mzimmersM 1 Reply Last reply
      0
      • M mchinand

        You probably need to add the following to your CMakeLists.txt file:

        set(CMAKE_AUTORCC ON)
        
        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @mchinand I did that as well (forgot to mention it in my original post).

        1 Reply Last reply
        0
        • mzimmersM Offline
          mzimmersM Offline
          mzimmers
          wrote on last edited by
          #4

          I found the problem. I changed the QML line above to:

                  source: "qrc:/icons/Home.png"
          

          And now it shows up just fine.

          1 Reply Last reply
          4

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved