dimanche 1 mars 2015

Accessing listview index in an extensible QML application


I'm doing an extensible QML application, it means that some of the components are loaded according to the "plugins" loaded on the application.


One of the situations is the following.


I've a ListView, and some of the elements shown on the ListView delegate are loaded based on the plugins. To create the component/object I use the functions: Qt.createComponent and component.createObject


It works great, and I can see and interact with the qml components loaded.


However, for some of the features I need to change the listview index from inside a plugin qml file (that is loaded on a delegated), but the index is not accessible from there, and I get a simple index is not defined When trying to.


The code is on github: The extension file is this one: http://ift.tt/1DrzHDt


The specific part I need to access the index is on the clicked signal of mousearea of element with id playpause.


I also tried finding the ListView element, and calling the function indexAt with the x, y mouse coordinates, but it's always returning 0.


The specific code that loads the component is this one:



Component.onCompleted: {
addTaskLayout.inputObjects = Extensions.createExtensionComponent("extraInput.qml", addTaskLayout);
}


And this function is a javascript function that is in this file: http://ift.tt/1Buw6rI


Let me know if you need more details, and I would love to understand why QML don't expose the index to loaded components and why it can't find the index even with x,y coordinates.


I'm using Qt5.4, Ubuntu 14.10, Qt Creator 3.3.1





Aucun commentaire:

Enregistrer un commentaire