Switch shown windows by changing integer in additional .qml file
-
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:
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.