Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

lupdate_only: showing QML and C++ files twice.



  • 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?



  • 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?



  • 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.



  • 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?



  • @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


Log in to reply