
Originally Posted by
JaySDC
Even tough I understand what you say and the philosophy behind it, my coding knowledge is too limited to create the code. My skill can only try and customize an existing code based on examples.
Right, that's one of the reasons I suggested the simpler approach.
Creating a custom component in QML is very easy.
Basically you just copy part of the code you have to a new QML file for which you use a filename that matches the name of how you want to call your component in the QML file using it.
E.g. your code conceptually looks like this
import QtQuick 2.4
Item {
ListModel {
}
PathView {
....
}
}
import QtQuick 2.4
Item {
ListModel {
}
PathView {
....
}
}
To copy to clipboard, switch view to plain text mode
You then copy all code of that PathView section to a new file along side the original file, e.g. GameListView.qml
import QtQuick 2.4
PathView {
....
}
import QtQuick 2.4
PathView {
....
}
To copy to clipboard, switch view to plain text mode
The original file can then be changed to
import QtQuick 2.4
Item {
ListModel {
}
GameListView {
}
}
import QtQuick 2.4
Item {
ListModel {
}
GameListView {
}
}
To copy to clipboard, switch view to plain text mode
That does not work at this point because you have been referencing the list model inside the PathView.
But in fact you only needed the directory. so you add a property for that in GameListView.qml
PathView {
property string directory
....
FolderListModel {
id: gameListModel
nameFilters: ["*.png"]
folder: parent.directory
}
}
PathView {
property string directory
....
FolderListModel {
id: gameListModel
nameFilters: ["*.png"]
folder: parent.directory
}
}
To copy to clipboard, switch view to plain text mode
You can then use multiple GameListView instances
Item {
property int currentSubType: 0
GameListView {
visible: parent.currentSubType === 0
directory: subTypeModel.get(0).path;
}
GameListView {
visible: parent.currentSubType === 1
directory: subTypeModel.get(1).path;
}
}
Item {
property int currentSubType: 0
GameListView {
visible: parent.currentSubType === 0
directory: subTypeModel.get(0).path;
}
GameListView {
visible: parent.currentSubType === 1
directory: subTypeModel.get(1).path;
}
}
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks