File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 36
36
// / delegate: // ...
37
37
// / }
38
38
// / ```
39
+ // / [QAbstractItemModel]: https://doc.qt.io/qt-6/qabstractitemmodel.html
40
+ // / [Data Model]: https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html#qml-data-models
39
41
class ScriptModel : public QAbstractListModel {
40
42
Q_OBJECT;
41
43
// / The list of values to reflect in the model.
@@ -51,8 +53,19 @@ class ScriptModel: public QAbstractListModel {
51
53
// / > }
52
54
// / > ```
53
55
// / >
54
- // / > Note that we are using @@DesktopEntries .values because it will cause @@ScriptModel.values
56
+ // / > Note that we are using @@ObjectModel .values because it will cause @@ScriptModel.values
55
57
// / > to receive an update on change.
58
+ // /
59
+ // / > [!TIP] Most lists exposed by Quickshell are read-only. Some operations like `sort()`
60
+ // / > act on a list in-place and cannot be used directly on a list exposed by Quickshell.
61
+ // / > You can copy a list using spread syntax: `[...variable]` instead of `variable`.
62
+ // / >
63
+ // / > For example:
64
+ // / > ```qml
65
+ // / > ScriptModel {
66
+ // / > values: [...DesktopEntries.applications.values].sort(...)
67
+ // / > }
68
+ // / > ```
56
69
Q_PROPERTY (QVariantList values READ values WRITE setValues NOTIFY valuesChanged);
57
70
QML_ELEMENT;
58
71
You can’t perform that action at this time.
0 commit comments