QActions in QML

Kevin Krammer krammer at kde.org
Tue Oct 30 15:35:14 UTC 2012


On Tuesday, 2012-10-30, Sebastian Kügler wrote:
> On Tuesday, October 30, 2012 16:01:37 Kevin Krammer wrote:

> > In any case, I am curious what the use case of triggering a UI action is?
> > I mean any imperative portion of the QML could just invoke the script
> > function the action's onTriggered is calling, no?
> 
> In Plasma Desktop, we have pluggable actions, which exist as QActions for
> example in Corona (think of "Lock widgets", "Add Widgets", "Activities",
> etc.).
> 
> In order to do a fully functional containment (and toolbox) in QML, we need
> access to these actions, and we need to be able to trigger them. So,
> basically a QML button receives an action object from the C++ side and is
> able to call trigger on it when the button is clicked. The trigger()
> function in this case is not scripted, but lives "somewhere else".

Ah, now it makes sense :)
Just like plugging an action into a QMenu, QToolBar or setting it as a default 
action on a QToolButton.

Since trigger() is a slot, the QML runtime should not need anymore information 
than the thing being a QObject instance.

E.g. if you make any QObject available to the QML runtime by calling 
setContextProperty() on a declarative context, the QML code can invoke any of 
the object's slots no matter which subclass it is.

So the same thing should apply here as well I think.

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20121030/43b47466/attachment-0001.sig>


More information about the Plasma-devel mailing list