Qt 6.12 LTS is out! See what's new in the release
blog
Cannot assign to property of a property alias in reusable component
-
I'm trying to assign value to
content.padding, wherecontentis a property alias fromMyButton.qmlandpaddingis a property ofcontent. However, the complier shows Cannot assign to non-existent property padding, which confused me a lot.import QtQuick import QtQuick.Controls Window{ MyButton { content.padding: 10 } } // MyButton.qml import QtQuick import QtQuick.Controls Rectangle { property alias content: content Rectangle{ id: content property int padding: 0 } } -
I'm trying to assign value to
content.padding, wherecontentis a property alias fromMyButton.qmlandpaddingis a property ofcontent. However, the complier shows Cannot assign to non-existent property padding, which confused me a lot.import QtQuick import QtQuick.Controls Window{ MyButton { content.padding: 10 } } // MyButton.qml import QtQuick import QtQuick.Controls Rectangle { property alias content: content Rectangle{ id: content property int padding: 0 } }Maybe the double-naming gets confusing for QML engine? Try this:
property alias content: contentInternal Rectangle{ id: contentInternal -
Maybe the double-naming gets confusing for QML engine? Try this:
property alias content: contentInternal Rectangle{ id: contentInternal -
K Kamichanw has marked this topic as solved on