Unable to assign [undefined] to QQuickItem*
-
Hello,
There is small implementation in my code where i am trying to assign a property var to ShaderEffectSource Item, posting the code for better understanding
Screen.qml
Flickable { anchors.fill: parent contentHeight: flickItem.height clip: true flickableDirection: Flickable.VerticalFlick boundsBehavior: Flickable.StopAtBounds Item { id: flickItem ListView { id: list delegate: Item { //Some Implementation is there here ShaderEffectSource { id: option anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom width: parent.width/2 sourceItem: PageRegister.get(index) //getting warning at this line Unable to assign [undefined] to QQuickItem* } Connections { target: PageImageRegistry onItemInserted: { if (itemIndex === index) { option.sourceItem = PageRegister.get(index) } } } } } } }
PageRegister.qml
pragma Singleton import QtQuick 2.9 QtObject { property var store: new Object property string key: "key" function get(index) { var str = key + index return store[str] } function insert(item, index) { var str = key + index store[str] = item itemInserted(index) } signal itemInserted(int itemIndex) }
Can some one please help to resolve the error.
Thanks in advance !!
Regard's,
Rohith.G -
-
-
I thought as much, never the less, you still need an instance of PageRegister and refer to it via the id you give it. It won't work with just the class name :D
-
Hi @J-Hilk
The PageRegister contains a pragma of Singleton, if possible can you please post a sample code. I started to work on qml newly.Thanks in advance !!
@Rohith said in Unable to assign [undefined] to QQuickItem*:
The PageRegister contains a pragma of Singleton
oh, didn't see that
didn't know it existed and omg, can't say I like the existence of it either.are you sure this:
function get(index) { var str = key + index return store[str] }
does what you think it does ?
-
@Rohith said in Unable to assign [undefined] to QQuickItem*:
The PageRegister contains a pragma of Singleton
oh, didn't see that
didn't know it existed and omg, can't say I like the existence of it either.are you sure this:
function get(index) { var str = key + index return store[str] }
does what you think it does ?