Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Switch shown windows by changing integer in additional .qml file

Switch shown windows by changing integer in additional .qml file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 307 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.
  • P Offline
    P Offline
    Philomath-Qt
    wrote on last edited by
    #1

    Hi there,

    I hope you can help me find an easy solution for changing the shown windows/switching shown .qml files, by receiving an integer from another Runtime. In this example the integers are 3 and 4, so that are the "themes" that the windows displays:

    Unbenannt(2).png

    I don't know the right appraoch, most important is, that each "theme" has it's own .qml file, so one can edit them independetly. I don't care if the "themes" are windows, items are something else, but i have to use the integer properties of valuesSource.qml somehow in order two switch between them.

    currently i run two windows, leftWindow and rightWindow, in my main.cpp:

    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        QQmlContext* context = engine.rootContext();
        context->setContextProperty("data", myClass.data.get());
        engine.load(QUrl("qrc:/core/resources/qml/leftWindow.qml"));
        engine.load(QUrl("qrc:/core/resources/qml/rightWindow.qml"));
    
        return app.exec();
    }
    
    

    leftWindow.qml and rightWindow.qml simplified look like:

    Window {
        id: root
        visible: true
        width: 1024
        height: 600
    
        color: "darkblue"
        title: "Mainwindow"
    
        ValueSource {
            id: valueSource
        }
                Text {
                    id: indexText
                    text: valueSource.displayedValue
                    font.pixelSize: 50
                    color: "white"
    
    
                }
    
    
    }
    

    Instead of always showing the darkblue background and the Text, i want to be able to switch to other themes, which have a different background and display other objects.

    last but not least, i have one ValueSources.qml file, which receives the displayedNumber which are shown by the windows and additionally it receives integers, which should tell which window to show:

    Item {
    
        Connections {
            target: data
            function onLeftWindowChanged(Number) {
                leftWindow = Number;
            }
            function onRightWindowChanged(Number) {
                rightWindow = Number;
            }
            function onDisplayedValueChanged(Value) {
                displayedValue = Values;
            }
        }
        id: valueSource
        property real displayedValue: 0
        property int leftWindow: 0
        property int rightWindow: 0
    
    }
    
    

    Does someone has any suggestions?

    Thank you in advance and kind regards.

    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