Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Use qrc file from CMake
QtWS25 Last Chance

[SOLVED] Use qrc file from CMake

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 6.7k Views
  • 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.
  • T Offline
    T Offline
    th.thielemann
    wrote on last edited by
    #1

    I use CMake to organise my project. And I have some resource files (qml, png) within my application.

    I want to avoid to list resource files twice: in CMakeLists.txt and qrc file, therefore:

    • Added all resource files to qrc file
    • Wrote a cmake macro to parse the qrc file to see all resource files in QtCreator too

    So please comment what you think about this approach.

    Regards

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

      Hi,

      Why not use

      @qt5_add_resources(UI_RESOURCES myresources.qrc)

      add_executable(myexec
      …
      ${UI_RESOURCES})@

      ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        th.thielemann
        wrote on last edited by
        #3

        Possible I miss this aspect in my initial post, but do you see the files used in myresources.qrc in QtCreator's Project view? I do not. So I have to navigate through myresources.qrc. Not very handy from my point of view.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I'm not sure I'm following you correctly. Do you mean see the files themselves or the qrc file ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            th.thielemann
            wrote on last edited by
            #5

            I want to see both, myresources.qrc file and all files listed in it.
            But in the meantime I implemented another approach:
            List all the resources in a CMakeLists.txt and during build the myresources.qrc is generated and used as input for rcc tool.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              AFAIK, even with qmake you would need to add the files as OTHER_FILES if you want to have them shown both separately

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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