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. enums, qml, qmake and rcc

enums, qml, qmake and rcc

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

    Hallo!

    I created a simple test project:
    TestProject_Enums_Compat.pro

    QT += quick
    
    SOURCES += \
            main.cpp
    
    resources.files = main.qml
    resources.prefix = /$${TARGET}
    RESOURCES += resources
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    HEADERS += \
        definitions.h
    

    Then i add an enum in a namespace:
    definitions.h

    #include <QObject>
    
    namespace SETTINGS
    {
        Q_NAMESPACE
    
        enum EnumTest {
            VALUE_0,
            //VALUE_X,
            VALUE_1
        };
    
        Q_ENUM_NS(EnumTest)
    }
    

    I register it and start a qml app:
    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    #include "definitions.h"
    
    int main(int argc, char *argv[])
    {
        qmlRegisterUncreatableMetaObject(SETTINGS::staticMetaObject, "Settings", 1, 0, "SETTINGS", QStringLiteral("SETTINGS should not be created in QML"));
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/TestProject_Enums_Compat/main.qml"));
        QObject::connect(
            &engine,
            &QQmlApplicationEngine::objectCreated,
            &app,
            [url](QObject *obj, const QUrl &objUrl) {
                if (!obj && url == objUrl)
                    QCoreApplication::exit(-1);
            },
            Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    

    My qml code is also very simple:
    main.qml

    import QtQuick
    import Settings 1.0
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Enum Test Project")
    
        Component.onCompleted: console.debug("IS: " + value_1 + "  SHOULD BE: " + SETTINGS.VALUE_1)
    
        property int value_1: SETTINGS.VALUE_1
    }
    
    

    And here the bug:

    When i change the enum, e.g. adding VALUE_X, i get the following output:
    IS: 1 SHOULD BE: 2

    So, i made a clean rebuild: same output
    I deleted the build folder: same output
    I reset all project configurations: same output
    I reset the qml code model: same output
    I closed the project, closed QtCreator, deleted the build folder, i even rebooted my computer: same output

    Note, i still use qmake.
    It works as expected with cmake.
    It works when i build the project with another Qt version.
    It also works when i activate the Qt-Quick-Compiler.
    And it works, when i overwrite main.qml (without making any changes).
    But i still get the same output, when i copy all files to another folder!
    You can see the complete content of all involved files above...

    So how can that be?
    Does the rcc use some sort of cache?

    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