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 3636// / delegate: // ...
3737// / }
3838// / ```
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
3941class ScriptModel : public QAbstractListModel {
4042 Q_OBJECT;
4143 // / The list of values to reflect in the model.
@@ -51,8 +53,19 @@ class ScriptModel: public QAbstractListModel {
5153 // / > }
5254 // / > ```
5355 // / >
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
5557 // / > 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+ // / > ```
5669 Q_PROPERTY (QVariantList values READ values WRITE setValues NOTIFY valuesChanged);
5770 QML_ELEMENT;
5871
You can’t perform that action at this time.
0 commit comments