I can not find a way to use a loader to fill a tab within a tabview. The loader works fine when it is outside of the TabView (ie if I remove the multi line comment characters at the top of mainTrial.qml and the Loader plus Connections are at the top. But if I move the Loader in line as a child of a tab, I get an error "Cannot assign multiple values to a singular property. Neither can I address the Loader that is outside of TabView using menuLoader.source or column1.menuLoader.source or other variants. Here is the main file. (the other two files that define the signals are included so that you can see that the signals work). What am I doing wrong?
Edit: (Good ole law of permutations and combinations) I discovered that if I make the Connections declaration, a child of the Loader that is on the tab, the problem goes away. I will have but one "value" assigned on the tab - that being the Loader and now I can load a qml item per tab.
//mainTrial
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
Item {
id: trial
width: 360
height: 360
ColumnLayout {
id: column1
spacing:150
Item {Layout.fillHeight: true}
TabView {
id: tabPages
Tab {
id: welcomePage
title: "Welcome"
// /*
Loader{
id: menuLoader
source: "mainTrial1.qml"
anchors.top: parent.top
Connections {
id: menuConnection
ignoreUnknownSignals: true
target: menuLoader.item
onMainTrial3: {
menuLoader.source = "mainTrial3.qml"
console.log("originated from " + origin)
}
onMainTrial1: {
menuLoader.source = "mainTrial1.qml"
console.log("originated from " + origin)
}
}
}
}
Tab {
id: statusPage
title: "Status"
}
}
}
}
// mainTrial1 (with one signal definition)
This file defines one of the signals used to load the next qml object. I included it here so that you can see that the signal works).
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
Item {
id: page1
property string origin: "Hello"
signal mainTrial3(string origin)
ColumnLayout {
spacing: 15
Rectangle {
width: 100
height: 62
color: "red"
MouseArea {
anchors.fill: parent
onClicked: {
mainTrial3("origin = from MouseArea")
}
}
}
Button {
text: "Sorting and scanning"
onClicked: {
mainTrial3(origin = "from Button")
}
}
}
}
//mainTrial3 (with the other signal definition)
This file defines the other signal used to reload the previous qml object. I included it here so that you can see that both signals work when one clicks on the rectangles).
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
Item {
id: page3
property string origin: "Hello"
signal mainTrial1(string origin)
GridLayout {
columnSpacing: 5
rowSpacing: 5
columns: 1
Rectangle {
width: 100
height: 62
color: "blue"
MouseArea{
anchors.fill: parent
onClicked: {
mainTrial1(origin = "from MouseArea1")
}
}
}
Rectangle {
width: 100
height: 62
color: "blue"
MouseArea{
anchors.fill: parent
onClicked: {
mainTrial1("from MouseArea2")
}
}
}
}
}