Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to build qrc resources into static library?
Qt 6.12 LTS is out! See what's new in the release blog

How to build qrc resources into static library?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k Views 1 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.
  • MozzieM Offline
    MozzieM Offline
    Mozzie
    wrote on last edited by
    #1

    Hi,
    when I call a function belong to a static library, I found the image which is added to the static library return a null image.
    After moving the .qrc file and all the image files to the application project, the image was correct finally.

    qDebug() << QImage(":/res/picture/status_red.png");
    

    Is there any way to build qrc resources into static library? rather than copy the resource file to another project.

    Thank you.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Did you try with
      https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
      "The Q_INIT_RESOURCE() macro is necessary on some platforms for resources stored in a static library."
      as stated here
      https://doc.qt.io/qt-5/resources.html

      MozzieM 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        Did you try with
        https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
        "The Q_INIT_RESOURCE() macro is necessary on some platforms for resources stored in a static library."
        as stated here
        https://doc.qt.io/qt-5/resources.html

        MozzieM Offline
        MozzieM Offline
        Mozzie
        wrote on last edited by
        #3

        @mrjj

        Thank you very much, It works!

        1 Reply Last reply
        1

        • Login

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