I've a virtual keyboard which pops-up from the bottom of the screen and always stays on top. I'm going to use this in my application and have a small problem.
If the text input field which accepts input from this keyboard is in middle / bottom of the view (main window / screen), it gets hidden behind the keyboard i.e., can't see whats been entered until the keyboard is hidden.
Keyboard is running as platforminputcontext plugin which will know the field that is accepting the input.
void KeyboardPlatformInputContext::setFocusObject(QObject* object)
{
qDebug() << m_focusedObject << object;
m_focusedObject = object;
}
When the keys are pressed, they are passed as QEvents like this
void KeyboardPlatformInputContext::processNormalKeyClick(const QString& key)
{
qDebug() << m_focusedObject << key;
if (m_focusedObject) {
QInputMethodEvent inputEvent;
inputEvent.setCommitString(key);
QGuiApplication::sendEvent(m_focusedObject, &inputEvent);
}
}
Now, with the available information (m_focusedObject and QGuiApplication) can it be possible to do something to keep the input field in view. Always.
Kuba has the right idea; I'll just expand on it. You can use Flickable, for example, to manage the content of your application. For example, suppose your application was laid out like a form:
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
id: root
width: 480
height: 800
visible: true
Column {
anchors.fill: parent
anchors.margins: 20
spacing: 20
Repeater {
model: 20
Row {
spacing: 20
Text {
text: "Input #" + (index + 1)
anchors.verticalCenter: parent.verticalCenter
}
TextInput {
width: 100
height: 30
onActiveFocusChanged: {
if (activeFocus)
keyboardRect.visible = activeFocus
}
Rectangle {
border.width: 1
anchors.fill: parent
anchors.margins: -1
z: -1
}
}
}
}
}
Rectangle {
id: keyboardRect
width: parent.width
height: parent.height * 0.3
anchors.bottom: parent.bottom
color: "grey"
visible: false
}
}
To make it usable with a virtual keyboard, move the content into a Flickable:
import QtQuick 2.0
import QtQuick.Window 2.0
Window {
id: root
width: 480
height: 800
visible: true
Flickable {
id: flickable
anchors.fill: parent
anchors.margins: 20
anchors.bottomMargin: keyboardRect.visible ? keyboardRect.height : anchors.margins
contentWidth: column.implicitWidth
contentHeight: column.implicitHeight
flickableDirection: Flickable.VerticalFlick
Column {
id: column
spacing: 20
Repeater {
model: 20
Row {
spacing: 20
Text {
text: "Input #" + (index + 1)
anchors.verticalCenter: parent.verticalCenter
}
TextInput {
width: 100
height: 30
onActiveFocusChanged: {
if (activeFocus) {
keyboardRect.visible = activeFocus
var posWithinFlickable = mapToItem(column, 0, height / 2);
flickable.contentY = posWithinFlickable.y - flickable.height / 2;
}
}
Rectangle {
border.width: 1
anchors.fill: parent
anchors.margins: -1
z: -1
}
}
}
}
}
}
Rectangle {
id: keyboardRect
width: parent.width
height: parent.height * 0.3
anchors.bottom: parent.bottom
color: "grey"
visible: false
}
}
A few things to note:
anchors.bottomMargin: keyboardRect.visible ? keyboardRect.height : anchors.margins
This ensures that the content is "pushed" up when the keyboard is visible, so that nothing is hidden below it.
onActiveFocusChanged: {
if (activeFocus) {
keyboardRect.visible = activeFocus
var posWithinFlickable = mapToItem(column, 0, height / 2);
flickable.contentY = posWithinFlickable.y - flickable.height / 2;
}
}
This code doesn't account for losing focus and hence the keyboard always stays open.
We focus the Flickable on the current input field by mapping the position of the field to the Column.
Finally, you'll see a bit of jumping around when you click on the fields near the top or bottom of the column. This can be probably solved by not setting the contentY if the field is near the top or bottom. An exercise for the reader. :)
For me correct answer is above (first one) plus following:
https://doc.qt.io/qt-5/qtvirtualkeyboard-deployment-guide.html#creating-inputpanel
import QtQuick 2.0
import QtQuick.VirtualKeyboard 2.1
Item {
id: root
Item {
id: appContainer
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: inputPanel.top
...
}
InputPanel {
id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
}
Quote:
The input panel must be a sibling element next to the application
container. It is important not to put the input panel within the
application container, as it would then overlap with the contents of
the application. Also, the input panel height will be automatically
updated according to the available width; the aspect ratio of the
input panel is constant.
Related
I am trying to add vertical scrollbar, as needed, to a ListView. I have been told that the best approach is to place the ListView inside a ScrollView, instead of inserting a scrollbar into the ListView (like in this question), because that would make it more efficient for the GPU.
I inserted it, as in the example below - but no matter what I tried, if the scroll bar shows, its handle always takes the entire height and of course doesn't move.
I hope you can take a look at my sample and give me a suggestion, why the scroll bar is not showing up properly.
There are comments inside the code explaining what I did and why.
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
Item
{
readonly property int parentWidth: 280
readonly property int parentMaxHeight: 400
// Main reason for doing this - the items are custom objects and
// their width does not automatically adjust for having the scroll bar or not
// But also, to set scroll bars because Qt.ScrollBarAsNeeded makes them not show
property bool scrollBarVisible: myListView.contentHeight > myListView.height
width: parentWidth
height: parentMaxHeight
Rectangle
{
id: myMenuRect
anchors.rightMargin: 2
anchors.leftMargin: 2
anchors.bottomMargin: 4
anchors.topMargin: 4
width: parentWidth
height: myListView.height
radius: 10
z: 2
color: "red" // Adding this to show why the height of the rectangle must match the listview
}
ScrollView
{
id: myScrollView
parent: myMenuRect
anchors.fill: parent
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.rightMargin: 5
frameVisible: false
// I have tried to set implicitHeight in many different ways,
// no matter what I do the scroll bar handle occupies the enire bar and doesn't move
// The Qt.ScrollBarAsNeeded didn't work... so I did this
verticalScrollBarPolicy: scrollBarVisible ? Qt.ScrollBarAlwaysOn : Qt.ScrollBarAlwaysOff
// Adding colors on scrollbar to show which part is showing
style: ScrollViewStyle
{
handle: Rectangle
{
implicitWidth: 10
implicitHeight: 2
radius: 10
anchors.leftMargin: 1
anchors.left: parent.left
color: "yellow"
}
scrollBarBackground: Rectangle
{
implicitWidth: 12
anchors.right: parent.right
color: "green"
}
}
ListView
{
id: myListView
parent: myScrollView
model: wifiComboListModel
focus: true
clip: true
interactive: false
width: parent.width
// I am trying to tell my view to take the minimum space it needs that is below
// a certain height. Ignore the "myListView." prefixes here, I know they are not needed but
// make it easier to move this outside if needed
height: (myListView.contentHeight > 0 ?
(myListView.contentHeight < parentMaxHeight ?
myListView.contentHeight : parentMaxHeight) : 0)
// I made this as simple as possible, without affecting "quality"
delegate: Text
{
text: _comboBoxText
height: 70
width: parent.width - 20
}
}
ListModel
{
id: wifiComboListModel
}
// I want to populate my model from outside, not be static. Not sure if this affects the bars
function populateComboBoxListModel()
{
wifiComboListModel.clear();
for (var itemIndex = 0; itemIndex < listItems.length; itemIndex++)
{
wifiComboListModel.append
({
_id: itemIndex,
_comboBoxText: listItems[itemIndex]
});
}
}
Component.onCompleted:
{
populateComboBoxListModel();
}
property var listItems: [
"This",
"annoying",
"list",
"view",
"does",
"not behave the way",
"I expect.",
"I",
"tried many",
"things,",
"now I am",
"begging for your",
"help",
"."
]
}
you have a binding loop for height in myMenuRect. This occurs because myMenuRect depends on height of the list view and vice versa. After fixing it seems to be working:
import QtQuick 2.0
import QtQuick.Controls 1.4
ApplicationWindow
{
readonly property int parentWidth: 280
readonly property int parentMaxHeight: 400
visible: true
// Main reason for doing this - the items are custom objects and
// their width does not automatically adjust for having the scroll bar or not
// But also, to set scroll bars because Qt.ScrollBarAsNeeded makes them not show
property bool scrollBarVisible: myListView.contentHeight > myListView.height
width: parentWidth
height: parentMaxHeight
Rectangle
{
id: myMenuRect
anchors.rightMargin: 2
anchors.leftMargin: 2
anchors.bottomMargin: 4
anchors.topMargin: 4
width: parentWidth
height: parentMaxHeight
radius: 10
z: 2
}
ScrollView
{
id: myScrollView
parent: myMenuRect
anchors.fill: parent
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.rightMargin: 5
frameVisible: false
// I have tried to set implicitHeight in many different ways,
// no matter what I do the scroll bar handle occupies the enire bar and doesn't move
// The Qt.ScrollBarAsNeeded didn't work... so I did this
verticalScrollBarPolicy: scrollBarVisible ? Qt.ScrollBarAlwaysOn : Qt.ScrollBarAlwaysOff
ListView
{
id: myListView
model: wifiComboListModel
focus: true
clip: true
interactive: false
width: parent.width
// I am trying to tell my view to take the minimum space it needs that is below
// a certain height. Ignore the "myListView." prefixes here, I know they are not needed but
// make it easier to move this outside if needed
height: (myListView.contentHeight > 0 ?
(myListView.contentHeight < parentMaxHeight ?
myListView.contentHeight : parentMaxHeight) : 0)
// I made this as simple as possible, without affecting "quality"
delegate: Text
{
text: _comboBoxText
height: 70
width: parent.width - 20
}
}
}
ListModel
{
id: wifiComboListModel
}
// I want to populate my model from outside, not be static. Not sure if this affects the bars
function populateComboBoxListModel()
{
wifiComboListModel.clear();
for (var itemIndex = 0; itemIndex < listItems.length; itemIndex++)
{
wifiComboListModel.append
({
_id: itemIndex,
_comboBoxText: listItems[itemIndex]
});
}
}
Component.onCompleted:
{
populateComboBoxListModel();
}
property var listItems: [
"This",
"annoying",
"list",
"view",
"does",
"not behave the way",
"I expect.",
"I",
"tried many",
"things,",
"now I am",
"begging for your",
"help",
"."
]
}
The reason why my ScrollView did not behave was parenthood :)
The issue: even though I set the parent in the ListView, it seems it did not take:
ListView
{
parent: myScrollView
What I had to do to make it work was actually nest the ListView inside the ScrollView.
ScrollView
{
id: myScrollView
parent: myMenuRect
anchors.fill: parent
ListView
{
id: myListView
model: wifiComboListModel
I think the "parent" property may not work well for all controls, and will remember that in the future.
Could anyone point me in the right direction on how to best organise my QML?
Currently for common single components I make a new QML file and add it to a Common directory under my resources.
E.g. My Label.qml
Text{
width: parent.width * 0.5
height: parent.height * 0.1
color: "#ffffff"
font.underline: true
font.pointSize: 16
verticalAlignment: Text.AlignBottom
horizontalAlignment: Text.AlignLeft
}
And then in my Form.qml I can import and use it like this:
import "Common"
Page {
Label{
id: username_lbl
text: "Username"
anchors.topMargin: parent.height * 0.1
}
...
}
But how would I do the above if I want to group together multiple components and reference them for use with connections?
For example I'd like a pair of buttons that sit at the bottom of a page (below is just an example and doesn't work):
So I'd like to have a ButtonPair.qml which would like a bit like this:
Button {
id: left_btn
width: parent.width * 0.5
height: parent.height * 0.1
anchors.bottom: parent.bottom
anchors.right: parent.right
}
Button {
id: right_btn
width: parent.width * 0.5
height: parent.height * 0.1
anchors.bottom: parent.bottom
anchors.left: parent.left
}
And then in my Form.qml I'd like to use these buttons and add an event handler to each:
import "Common"
Page {
ButtonPair{id: back_forward_buttons}
Connections {
target: back_forward_buttons.left_btn
onClicked: {
stackView.pop();
}
Connections {
target: back_forward_buttons.right_btn
onClicked: {
stackView.push("AnotherPage.qml");
}
}
Do I need to wrap my ButtonPair in a Component and use a Loader on my page and if so how do I then get to the individual left/right buttons in order to bind to onClicked?
When a component is designed, it is considered a black box that has properties and signals that must be viewed from the outside.
For example in your case ButtonPair must expose 2 signals: one when the left button is pressed and another when the right button is pressed, another thing that I have added are 2 properties to be able to establish the name of the buttons.
I see that you have set the height of the buttons as 10% of the height of the father and should be in the lower part and if you want to use that same component on the top? I would have to create another topButtonPair component, and if I want them to be on the right, etc. For the size should be established when the component is created not in the implementation. In this case each button must occupy half of the parent item.
Using the above we obtain the following:
ButtonPair.qml
import QtQuick 2.0
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
Item{
// expose properties and signals
property string leftname: ""
property string rightname: ""
signal leftClicked()
signal rightClicked()
// internals
RowLayout{
anchors.fill: parent
spacing: 0
Button {
text: leftname
onClicked: leftClicked()
Layout.fillWidth: true
Layout.fillHeight: true
}
Button {
text: rightname
onClicked: rightClicked()
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
Note: The use of the layout is optional, you could use the anchors.
Now used on the page:
Page {
// other components
ButtonPair{
anchors.bottom: parent.bottom
height: 0.1*parent.height // <--- Here the height is established
anchors.left: parent.left
anchors.right: parent.right
leftname: "left text"
rightname: "right text"
onLeftClicked: console.log("left clicked")
onRightClicked: console.log("right clicked")
}
}
Generally, the black-box appraoch taken by #eyllanesc is the better one and should be preferred whenever possible. However, if you really need to access child items from the outside, you can:
ButtonPair.qml:
Item {
property alias leftButton: left_btn
property alias rightButton: right_btn
// … declarations of left_btn and right_btn as in your question
}
Usage:
ButtonPair {
leftButton {
onClicked: {
stackView.pop();
}
}
rightButton {
onClicked: {
stackView.push("AnotherPage.qml");
}
}
}
You can also use it in Connections. However, in 95% of cases you should forward properties and signals as in #eyllanesc’s approach, which leads to a much cleaner and readable interface.
I have a SwipeView that loads its internal elements through a Repeater and a Loader.
I would like to swipe between the items forward and backward by just clicking the arrows on the right and left of the SwipeView.
How can I implement this behavior in QML?
SwipeView {
id: __swipeView
Layout.fillHeight: true
Layout.fillWidth: true
Repeater {
model: 3
Loader {
source: "qrc:/../SwipeDelegate.qml"
}
}
}
Within your delegate, you can access the SwipeView via the SwipeView attached property, and then increment or decrement the current index as necessary:
import QtQuick 2.6
import QtQuick.Controls 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
anchors.fill: parent
Repeater {
model: 3
Item {
id: delegate
Button {
text: "<"
enabled: index > 0
onClicked: delegate.SwipeView.view.decrementCurrentIndex()
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
}
Label {
text: "Page " + (index + 1)
anchors.centerIn: parent
}
Button {
text: ">"
enabled: index < delegate.SwipeView.view.count - 1
onClicked: delegate.SwipeView.view.incrementCurrentIndex()
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
}
}
}
It's important to use the functions as opposed to setting currentIndex directly, for the reasons described here.
I am using a ComboBox in QML and when populated with a lot of data it exceeds my main windows bottom boarder. From googling I have learned that the drop-down list of a ComboBox is put on top of the current application window and therefore it does not respect its boundaries.
Ideally I would want the ComboBox to never exceed the main applications boundary, but I can not find any property in the documentation.
A different approach would be to limit the number of visible items of the drop-down list so that it do not exceed the window limits for a given window geometry. I was not able to find this in the documentation either and I have run out of ideas.
Take a look to the ComboBox source code, the popup is of a Menu type and it doesn't have any property to limit its size. Moreover, the z property of the Menu is infinite, i.e. it's always on top.
If you Find no way but to use the ComboBox of Qt you can create two models one for visual purpose, I will call it visual model, you will show it in your ComboBox and the complete one , it will be the reference model. Items count in your VisualModel wil be equal to some int property maximumComboBoxItemsCount that you declare . you'll need o find a way that onHovered find the index under the mouse in the visualmodel if it's === to maximumComboBoxIemsCount you do visualModel.remove(0) et visualModel.add(referenceModel.get(maximum.. + 1) and you'll need another property minimumComboBoxIemsCount, same logic but for Scroll Up , I dont know if it will work. but it's an idea
I think there is no solution using the built-in component and you should create your own comboBox. You can start from the following code.
ComboBox.qml
import QtQuick 2.0
Item {
id: comboBox
property string initialText
property int maxHeight
property int selectedItem:0
property variant listModel
signal expanded
signal closed
// signal sgnSelectedChoice(var choice)
width: 100
height: 40
ComboBoxButton {
id: comboBoxButton
width: comboBox.width
height: 40
borderColor: "#fff"
radius: 10
margin: 5
borderWidth: 2
text: initialText
textSize: 12
onClicked: {
if (listView.height == 0)
{
listView.height = Math.min(maxHeight, listModel.count*comboBoxButton.height)
comboBox.expanded()
source = "qrc:/Images/iconUp.png"
}
else
{
listView.height = 0
comboBox.closed()
source = "qrc:/Images/iconDown.png"
}
}
}
Component {
id: comboBoxDelegate
Rectangle {
id: delegateRectangle
width: comboBoxButton.width
height: comboBoxButton.height
color: "#00000000"
radius: comboBoxButton.radius
border.width: comboBoxButton.borderWidth
border.color: comboBoxButton.borderColor
Text {
color: index == listView.currentIndex ? "#ffff00" : "#ffffff"
anchors.centerIn: parent
anchors.margins: 3
font.pixelSize: 12
text: value
font.bold: true
}
MouseArea {
anchors.fill: parent
onClicked: {
listView.height = 0
listView.currentIndex = index
comboBox.selectedItem = index
tools.writePersistence(index,5)
comboBoxButton.text = value
comboBox.closed()
}
}
}
}
ListView {
id: listView
anchors.top: comboBoxButton.bottom
anchors.left: comboBoxButton.left
width: parent.width
height: 0
clip: true
model: listModel
delegate: comboBoxDelegate
currentIndex: selectedItem
}
onClosed: comboBoxButton.source = "qrc:/Images/iconDown.png"
Component.onCompleted: {
var cacheChoice = tools.getPersistence(5);
listView.currentIndex = tools.toInt(cacheChoice)
selectedItem = listView.currentIndex
comboBoxButton.text = cacheModel.get(selectedItem).value
}
}
ComboBoxButton.qml
import QtQuick 2.0
Item {
id: container
signal clicked
property string text
property alias source : iconDownUp.source
property string color: "#ffffff"
property int textSize: 12
property string borderColor: "#00000000"
property int borderWidth: 0
property int radius: 0
property int margin: 0
Rectangle {
id: buttonRectangle
anchors.fill: parent
color: "#00000000"
radius: container.radius
border.width: container.borderWidth
border.color: container.borderColor
Image {
id: image
anchors.fill: parent
source: "qrc:/Images/buttonBackground.png"
Image {
id: iconDownUp
source: "qrc:/Images/iconDown.png"
sourceSize.height:20
sourceSize.width: 20
anchors.verticalCenter: parent.verticalCenter
}
}
Text {
id:label
color: container.color
anchors.centerIn: parent
font.pixelSize: 10
text: container.text
font.bold: true
}
MouseArea {
id: mouseArea;
anchors.fill: parent
onClicked: {
container.clicked()
buttonRectangle.state = "pressed"
startTimer.start()
}
}
Timer{
id:startTimer
interval: 200
running: false;
repeat: false
onTriggered: buttonRectangle.state = ""
}
states: State {
name: "pressed"
when: mouseArea.pressed
PropertyChanges { target: image; scale: 0.7 }
PropertyChanges { target: label; scale: 0.7 }
}
transitions: Transition {
NumberAnimation { properties: "scale"; duration: 200; easing.type: Easing.InOutQuad }
}
}
}
I've used it in some software of mine, hence it is possible that It could not work "out of the box". I use it like this:
ComboBox{
id:cacheChoice
initialText: "None"
anchors.top: baseContainer.top
anchors.topMargin: 2
anchors.right: baseContainer.right
maxHeight: 500
listModel: cacheModel
onExpanded: {
cacheChoice.height = 500
}
onClosed: {
cacheChoice.height = 20
}
}
In case you are working with ComboBox from Qt Quick Controls 2, here's the source code for it:
https://github.com/qt/qtquickcontrols2/blob/5.12/src/imports/controls/ComboBox.qml
Based on that, this override of the behavior works to limit the height to something reasonable:
myComboBox.popup.contentItem.implicitHeight = Qt.binding(function () {
return Math.min(250, myComboBox.popup.contentItem.contentHeight);
});
It is possible to access the hidden MenuStyle within the ComboBoxStyle component. There you can use all the things and hidden things you have within a MenuStyle, including its maximum height.
The thing looks roughly like this.
Not pretty but it works well enough.
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.3
import QtQuick.Window 2.2
ComboBox {
id: comboBox
style: ComboBoxStyle {
// drop-down customization here
property Component __dropDownStyle: MenuStyle {
__maxPopupHeight: 400
__menuItemType: "comboboxitem" //not 100% sure if this is needed
}
}
As it came up resonantly in our team, here is a updated version of the idea shown above. The new version restricts the size automatically to the size of your application.
ComboBox {
id: root
style: ComboBoxStyle {
id: comboBoxStyle
// drop-down customization here
property Component __dropDownStyle: MenuStyle {
__maxPopupHeight: Math.max(55, //min value to keep it to a functional size even if it would not look nice
Math.min(400,
//limit the max size so the menu is inside the application bounds
comboBoxStyle.control.Window.height
- mapFromItem(comboBoxStyle.control, 0,0).y
- comboBoxStyle.control.height))
__menuItemType: "comboboxitem" //not 100% sure if this is needed
} //Component __dropDownStyle: MenuStyle
} //style: ComboBoxStyle
} //ComboBox
In my application i show a nested list, that shows groups and folders as its children. I have built the functions necesary to generate a new list in the backend in c++ based on which item is clicked by the user.
I allready have the necesary functionality to pass the list to qml through QProperty.
so my question is, how do i previous listviews and show new ones dynamically. Considering it should also be possible to click the button "back", which should load the previous page again showing the groups and the folders.
this is the code i have now, showing the groups and its children(folders)
import QtQuick 2.4
import QtQuick.Window 2.2
//import ListMode 1.0
Rectangle {
height: 250
width: 140
color: "pink"
//property var aNum: 0
Component {
id: folderDelegate
Item {
width: 140
height: col2.childrenRect.height
Column {
id: col2
anchors.left: parent.left
anchors.right: parent.right
Rectangle {
height: 20
width: parent.width
border.color: "black"
MouseArea {
anchors.fill: parent
onClicked: treemodel.getObject(model.ID + ":" + model.Name)
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
id: name1
text: model.Name
}
}
}
}
}
ListView {
id: outer
model: myModel
delegate: groupsDelegate
anchors.fill: parent
}
Component {
id: groupsDelegate
Item {
width: 140
height: col.childrenRect.height
Column {
id: col
anchors.left: parent.left
anchors.right: parent.right
Text {
anchors.horizontalCenter: parent.horizontalCenter
id: t1
font.bold: true
font.underline: true
font.pointSize: 9
text: model.Name
}
ListView {
id: folderlist
model: treemodel.lists[treemodel.modIndex]
delegate: folderDelegate
contentHeight: contentItem.childrenRect.height
height: childrenRect.height
anchors.left: parent.left
anchors.right: parent.right
clip: true
}
}
}
}
}
i have been reading documentations and searching forums, but the information is pretty overwhelming. So a pointer in the right direction would be appreciated.
the main model is setup for each item to have its own unique ID. So when an item is clicked, i run a function that grabs and stores the item based on the ID + name that was clicked
MouseArea {
anchors.fill: parent
onClicked :{
treemodel.getObject(model.ID + ":" + model.Name)
stackView.push(Qt.resolvedUrl("content/ButtonPage.qml"))
}
}
next, based on the item that was clicked i have functions that fill different QList items which are loaded into the ButtonPage.qml.
the function in c++ that is invoked is:
Q_INVOKABLE void getObject(QString index) {
clickedItemID = index;
getClickedItem();
getFilesByFolder();
}
now, i am not sure if this is a good solution. But for me it works. Maybe it will work for someone else too.