[Qt-qml] Executable code in a model?

Gregory Schlomoff gregory.schlomoff at gmail.com
Tue Nov 16 14:00:02 CET 2010


Easy, just bind your javascript code to a signal or a property.

QML version of your pseudo-code :

Menu {
  MenuItem {
    title: "save"
    onActivated: {
        var file = ....
        file.save();
    }
}


2010/11/16 Pertti Kellomäki <pertti.kellomaki at nokia.com>:
> Is it possible to have executable code as part of a model element? In a
> hypothetical Scheme based QML I could create a list model that contains
> <string, procedure> pairs, and then in a list view a delegate could
> simply call the procedure:
>
> (define file-menu
>   (list
>       (list "Save"
>              (lambda () (save-file)))  ; executable code
>       (list "Quit"
>              (lambda () (quit))))
>
> Does QML allow something like this, or is there some other convenient
> way to glue together e.g. labels and actions?
> --
> Pertti
>
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-qml
>




More information about the Qt-qml mailing list