Hello?
Is there anybody? I need your help :/
I have three files: ‘Main.qml’, ‘SimpleRowbutton.qml’ and ‘SimpleRowSwitch.qml’.
I want to Load to the AppListView SimpleRow with AppSwitch or AppButon, dependent of values of array:
property var typeOfElementsInSettings: ['switch','switch','button','switch','button','switch','switch','switch']
How i Can do It? I don’t have any idea, please give me the tip.
My code:
import Felgo 3.0
import QtQuick 2.9
Component{
SimpleRow {
text: "name";
AppButton{
text: "aaaa"
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: dp(10)
Component.onCompleted: {
console.log(myIndex)
console.log("Przycisk")
//myIndex++;
}
}
Component.onCompleted: {
console.log("bbb"+switchsSettingsLogicArray[myIndex])
//console.log(myIndex)
myIndex++
}
}
}
SimpleRowSwitch.qml:
import Felgo 3.0
import QtQuick 2.9
Component{
SimpleRow {
text: "name";
AppSwitch{
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: dp(10)
Component.onCompleted: {
console.log(myIndex)
if(switchsSettingsLogicArray[myIndex]===1){
checked=true
} else {
checked=false
}
//myIndex++;
}
onToggled: {
console.log(myIndex)
}
}
Component.onCompleted: {
console.log("a"+switchsSettingsLogicArray[myIndex])
//console.log(myIndex)
myIndex++
}
}
}
Main.qml (all):
import Felgo 3.0
import QtQuick 2.9
App {
//var appswitchs = {id: 1, value: false; id: 2, value: false};
id: app
property var switchsSettingsLogicArray: [0,0,1,1,1,0,0,1,1]
property var typeOfElementsInSettings: ['switch','switch','button','switch','button','switch','switch','switch']
property var firstRun
property int myIndex: 0
Navigation{
NavigationItem{
title: "Listy"
icon: IconType.checkcircle
NavigationStack{
Page{
id: task1
navigationBarTranslucency: 0.0
title: "Listy"
SearchBar {
id: searchBarThreads
onAccepted: {
}
}
}
}
}
NavigationItem{
title: "Konto użytkownika"
icon: IconType.user
NavigationStack{
Page{
title: "Konto użytkownia"
}
}
}
NavigationItem{
title: "Ustawienia"
icon: IconType.cogs
NavigationStack{
Page{
title: "Ustawienia"
AppListView{
model: ListModel{
ListElement{
type: "kategoria 1"; name: "opcja 1"
}
ListElement{
type: "kategoria 12"; name: "opcja 2"
}
ListElement{
type: "kategoria 23"; name: "opcja 3"
}
ListElement{
type: "Opcje programisty"; name: "Czyszczenie ustawień aplikacji"
}
ListElement{
type: "kategoria 11"; name: "opcja 1"
}
ListElement{
type: "kategoria 1"; name: "opcja 2"
}
ListElement{
type: "kategoria 2"; name: "opcja 3"
}
ListElement{
type: "Opcje programisty2"; name: "Czyszczenie ustawień aplikacji"
}
}
section.property: "type";
section.delegate: Component {
//title: section
}
delegate: Loader{
//asynchronous: true
//visible: status == Loader.Ready
sourceComponent: {
switch(typeOfElementsInSettings[myIndex]){
case "switch":
console.log("switch")
return SimpleRowButton.qml;
case "button":
console.log("button")
return SimpleRowButton.qml;
}
}
}
}
}
}
onSelected: {
//console.log("selected")
}
Component.onCompleted: {
//console.log("Zrobiono")
}
}
}
function init(){
console.log("initialization...")
}
Component.onCompleted: {
app.settings.clearAll()
if(app.settings.getValue("firstRun") === undefined){
console.log("firstRun: false")
init()
app.settings.setValue("firstRun", false)
}
}
}