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. Qt6 CMake qt_add_resources with LANG why does order matter ?
Forum Updated to NodeBB v4.3 + New Features

Qt6 CMake qt_add_resources with LANG why does order matter ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 110 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.
  • F Offline
    F Offline
    f222
    wrote last edited by
    #1

    I am doing some tests with Qt6 and CMake and while attempting to load I18N resources in my project I was faced with a strange behaviour I can't comprehend.

    When I try to include my resources like so:

    qt_add_resources(
        cmake_qt6_sample_project "images_fr"
        LANG "fr"
        BASE "${CMAKE_CURRENT_SOURCE_DIR}/assets/fr"
        FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/fr/images/doge.jpg"
    )
    qt_add_resources(
        cmake_qt6_sample_project "images"
        BASE "${CMAKE_CURRENT_SOURCE_DIR}/assets"
        FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/images/doge.jpg"
    )
    

    I can switch my locale FR to get the French picture with QPixmap background {u":/images/doge.jpg"_s};

    But if I switch the order in the CMakeLists like that:

    qt_add_resources(
        cmake_qt6_sample_project "images"
        BASE "${CMAKE_CURRENT_SOURCE_DIR}/assets"
        FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/images/doge.jpg"
    )
    qt_add_resources(
        cmake_qt6_sample_project "images_fr"
        LANG "fr"
        BASE "${CMAKE_CURRENT_SOURCE_DIR}/assets/fr"
        FILES "${CMAKE_CURRENT_SOURCE_DIR}/assets/fr/images/doge.jpg"
    )
    

    There is no way for me to get the French picture.

    Is there a reason/something I missed in the documentation explaining that behaviour. Did I do something wrong ?

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

      Hi,

      Which version of Qt are you using ?

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

      F 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Which version of Qt are you using ?

        F Offline
        F Offline
        f222
        wrote last edited by
        #3

        @SGaist I am using Qt 6.9.1 on Windows and am having this issue both with MSVC cl 2022 and clang-cl.
        Using ninja as the build system.

        I'm sorry for forgetting those details in the first place 😓.

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

          Would it be possible to provide a minimal compilable project to study that behavior ?

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

          F 1 Reply Last reply
          0
          • SGaistS SGaist

            Would it be possible to provide a minimal compilable project to study that behavior ?

            F Offline
            F Offline
            f222
            wrote last edited by
            #5

            @SGaist

            Yes of course, I've put a minimal compilable project to reproduce the issue on github: qt_cmake_localized_resources_issue

            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