[Development] Modifying QQmlFileSelector selector at runtime without Loader or Component

achartier at fastmail.fm achartier at fastmail.fm
Sat Dec 13 05:29:02 CET 2014


Hello,

I would like to modify the extraSelectors of QQmlFileSelector at runtime
and have QML load the new QML file from the appropriate selector folder.
I have gotten this to work by calling setExtraSelectors() from a C++
object I have exposed to QML and then forcing a re-evaluation of the
Loader's source property:

Loader {
     id: myLoader
     source: Qt.resolvedUrl("MyItem.qml")
}

Connections {
     target: myCppObject
     onSelectorChanged: myLoader.source = Qt.resolvedUrl("MyItem.qml")
}

Now, for my use case I really need the ability to achieve the same
behavior without using Loader or Component. I essentially want something
like this:

MyItem { }

Connections {
     target: myCppObject
     onSelectorChanged: // when selector changes, the MyItem instance
     above is automatically resolved to the MyItem definition in the
     appropriate selector folder.

How can this be accomplished?

Thanks!



More information about the Development mailing list