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. lupdate_only: showing QML and C++ files twice.
Forum Updated to NodeBB v4.3 + New Features

lupdate_only: showing QML and C++ files twice.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 3.3k 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.
  • E Offline
    E Offline
    EStudley
    wrote on last edited by EStudley
    #1

    I added translations to my application, but to allow lupdate to find my translations in the C++ and QML files, I need to include them like this:

    lupdate_only {
    SOURCES = src/*.cpp \
        src/*.h \
        qml/*.qml 
    }
    

    I already have them included individually under

    SOURCES += \
        src/main.cpp \
        src/ect.... \
    
    HEADERS += \
        src/myModel.h \
        src/ect.... \
    
    OTHER_FILES += \
        qml/main.qml \
        qml/ect.... \
    

    But now in QtCreator:

    My headers show up in Project / Headers / src (Correct)
    My QML shows up in Project / QML / qml (Correct)
    ALL my header and sources show up under Project / Sources / src / (Incorrect, should be just .cpp)
    My QML shows up in Project / Sources / qml (Incorrect, should not show QML under Sources)

    So it seems like lupdate_only put a copy of my QML and Header files and added them to my Sources subdirectory. Is there any way to exclude them being added to this list? I found this Qt bug, but a dev in the comments described it as not being a bug. How is showing a file twice not a bug?

    Any ideas?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      EStudley
      wrote on last edited by
      #2

      Bump, I'd really like to hear what anyone has to say about this. Should I be manually translating .qml and .cpp files with lupdate?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dynamo72
        wrote on last edited by
        #3

        lupdate automatically picks all SOURCES and HEADERS. The problem is just that it misses the QML files.
        So I use this construct:

        lupdate_only {
        SOURCES += $$OTHER_FILES
        }

        (and have my QML files in OTHER_FILES, of course).

        Take care, it should be double $ character.

        At least this prevents the Header files to appear in sources. The QML files are still in the Project / Sources / qml folder, though.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          EStudley
          wrote on last edited by
          #4

          Thanks, that really helps. The problem I was having was that lupdate couldn't find my C++ translation from files inside SOURCES either. Any idea why that could happen?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stcorp
            wrote on last edited by
            #5

            @EStudley @dynamo72
            This issue is still around. One workaround is to place the lupdate_only part in a .pri file, and include that .pri file in the .pro file.

            i18n.pri:

            lupdate_only {
                SOURCES += *.qml
            }
            

            project.pro:

            include(i18n.pri)
            

            This way, lupdate will still work properly, but QtCreator won't put all the QML files into your sources in the project browser

            1 Reply Last reply
            2

            • Login

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