Component objects cannot declare new properties
Moved
Solved
QML and Qt Quick
-
If I don't use
Button
element in theComponent
, it doesn't give me the above error.e.g. This works fine
Component { Row { Rectangle {..} Rectangle {..} Rectangle {..} Rectangle {..} } }
But if I add Button element as below, it gives me the mentioned error in the application output
Component { id: itemDelegate Button { .. } Row { Rectangle {..} Rectangle {..} Rectangle {..} Rectangle {..} } }
I'm using the Component as a delegate
-
@pingal said in Component objects cannot declare new properties:
But if I add Button element as below, it gives me the mentioned error in the application output
AFAIK,
Component
can hold only 1 root object (eg.Item
,Rectangle
,Row
ect.). It is same a creating a QML file for a component (cf. https://doc.qt.io/qt-5/qml-qtqml-component.html)
You should change your code to:Component { id: itemDelegate Item { Button { .. } Row { Rectangle {..} Rectangle {..} Rectangle {..} Rectangle {..} } } }