Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare list property in QML

Tags:

How do I declare a list property in QML (for use with Qt.labs.settings in my case):

Settings {
    property list recentFiles: []
}

Does not work. I've tried many other options: list<string>, string[], etc. None seem to work.

like image 413
Timmmm Avatar asked Nov 04 '14 10:11

Timmmm


People also ask

How do you use property in QML?

A property is an attribute of an object that can be assigned a static value or bound to a dynamic expression. A property's value can be read by other objects. Generally it can also be modified by another object, unless a particular QML type has explicitly disallowed this for a specific property.

What is property alias in QML?

Unlike an ordinary property definition, which allocates a new, unique storage space for the property, a property alias connects the newly declared property (called the aliasing property) as a direct reference to an existing property (the aliased property).

What is property in Qt?

The property type can be any type supported by QVariant, or it can be a user-defined type. In this example, class QDate is considered to be a user-defined type. Q_PROPERTY(QDate date READ getDate WRITE setDate) Because QDate is user-defined, you must include the <QDate> header file with the property declaration.


1 Answers

Settings {
    property var recentFiles: []
}

http://doc.qt.io/qt-5/qml-var.html

like image 145
fat Avatar answered Sep 21 '22 12:09

fat