Custom QML Properties

I am having trouble defining a custom property in a QML element:

Item {
    property MovieTileItem data
    Text {
        text: "Some text"
    }
}

MovieTitleItem is an element defined in a separate QML file:

import Qt 4.7

Item {
    property string title
    property string posterSource
}

The error I get is "Unable to assign property" by specifying a property declaration. Any ideas?

+3
source share
2 answers

โ€œUnable to assign object to propertyโ€ because a property such as โ€œdataโ€ already exists (and it is read-only):

http://qt-project.org/doc/qt-4.8/qml-item.html#data-prop

+7
source

, , qmlRegisterType(). , , , , .

Item {
    data:Custom{}
    Text {
        text: "Some text"
    }
}
+1

Source: https://habr.com/ru/post/1774079/


All Articles