33 lines
834 B
QML
33 lines
834 B
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
Item {
|
|
focus: true
|
|
property var sourceMap: ({})
|
|
Component.onCompleted: {
|
|
common.sig_changeQml.connect(changeQml)
|
|
common.sig_changeMainQml.connect(changeQml)
|
|
}
|
|
|
|
function changeQml(qmlName) {
|
|
if(!(qmlName in sourceMap))
|
|
{
|
|
const component = Qt.createComponent(qmlName);
|
|
if (component.status === Component.Ready) {
|
|
component.createObject(stackLayout, {})
|
|
stackLayout.currentIndex = stackLayout.count - 1
|
|
sourceMap[qmlName] = stackLayout.currentIndex
|
|
}
|
|
}
|
|
else{
|
|
stackLayout.currentIndex = sourceMap[qmlName]
|
|
}
|
|
}
|
|
|
|
StackLayout
|
|
{
|
|
id: stackLayout
|
|
anchors.fill: parent
|
|
}
|
|
}
|