I want to create Tabs. So using Tab bar and Tab buttons i am creating tabs and using stack layout i am loading the respecting screen.
Note: i dont want to use loader. Using only Stack layout how can i load the screen. Please suggest how can i do that?
Item {
id:screenTabs
property var tabname : [qsTr("Tab1"),qsTr("Tab2"),qsTr("Tab3"),qsTr("Tab4"),qsTr("Tab5")]
property var tabScreen : ["qrc:/Tabscreen1.qml","qrc:/Tabscreen2.qml","qrc:/Tabscreen3.qml","qrc:/Tabscreen4.qml","qrc:/Tabscreen5.qml"]
width : parent.width
height : parent.height
TabBar
{
id: bar
width: parent.width*0.95
anchors {
top: parent.top
topMargin: 15
left: parent.left
leftMargin: 10
}
Repeater
{
model: tabname.length
TabButton
{
text: tabname[index]
}
}
}
StackLayout
{
id: stacklyt
width: parent.width
height: parent.height
currentIndex: bar.currentIndex
anchors {
top: bar.bottom
}
Repeater
{
model: tabScreen.length
Loader
{
width: parent.width
height: parent.height
source: tabScreen[index]
}
}
}
}
Also without using loader i am doing below shown way but this is not what i am expecting:
StackLayout {
id: stackLayout
width: parent.width
height: parent.height
currentIndex: bar.currentIndex
anchors.top: bar.bottom
Item {
}
Item {
}
Item {
}
Item {
}
Item {
}
}