How to set properties of a property alias?
-
In Dummy.qml
import QtQuick Item { property alias dummy: dummy Item { id: dummy property int dummyInt: 0 } }
And I want to use
Dummy
in main.qml and set proprety ofdummy
directly, but an error occurred:Cannot assign to non-existent property "dummyInt"
Dummy { dummy.dummyInt: 1 }
-
In Dummy.qml
import QtQuick Item { property alias dummy: dummy Item { id: dummy property int dummyInt: 0 } }
And I want to use
Dummy
in main.qml and set proprety ofdummy
directly, but an error occurred:Cannot assign to non-existent property "dummyInt"
Dummy { dummy.dummyInt: 1 }
@Kamichanw said in How to set properties of a property alias?:
Item {
property alias dummy: dummyItem { id: dummy property int dummyInt: 0 }
}
This is because the alias thinks dummy is just an
Item
. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:
Item { property alias dummy: dummy component InnerDummy: Item { property int dummyInt: 0 } InnerDummy { id: dummy } }
-
In Dummy.qml
import QtQuick Item { property alias dummy: dummy Item { id: dummy property int dummyInt: 0 } }
And I want to use
Dummy
in main.qml and set proprety ofdummy
directly, but an error occurred:Cannot assign to non-existent property "dummyInt"
Dummy { dummy.dummyInt: 1 }
-
In Dummy.qml
import QtQuick Item { property alias dummy: dummy Item { id: dummy property int dummyInt: 0 } }
And I want to use
Dummy
in main.qml and set proprety ofdummy
directly, but an error occurred:Cannot assign to non-existent property "dummyInt"
Dummy { dummy.dummyInt: 1 }
@Kamichanw said in How to set properties of a property alias?:
Item {
property alias dummy: dummyItem { id: dummy property int dummyInt: 0 }
}
This is because the alias thinks dummy is just an
Item
. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:
Item { property alias dummy: dummy component InnerDummy: Item { property int dummyInt: 0 } InnerDummy { id: dummy } }
-
-
@Kamichanw said in How to set properties of a property alias?:
Item {
property alias dummy: dummyItem { id: dummy property int dummyInt: 0 }
}
This is because the alias thinks dummy is just an
Item
. Left-hand QML bindings only work if the full type is known. A js imperative assignment would work.To fix that you could create a standalone file for your inner type and use that in Dummy, or use an inline component:
Item { property alias dummy: dummy component InnerDummy: Item { property int dummyInt: 0 } InnerDummy { id: dummy } }