QActions in QML

Daker Fernandes Pinheiro dakerfp at gmail.com
Mon Oct 29 00:33:55 GMT 2012


Sebas,

This just worked:
http://paste.kde.org/584660/
Where QAction is
http://paste.kde.org/584672/

Cheers,

Daker Fernandes Pinheiro
http://codecereal.blogspot.com


2012/10/28 Sebastian Kügler <sebas at kde.org>

> On Thursday, October 25, 2012 20:00:25 Aaron J. Seigo wrote:
> > not automatically, no. but QActions are QObjects, so you can attach to
> their
> > signals in the QML.
>
> And it's quite wonky, for example offering a list of QActions
> (QDeclarativeListProperty or QList, even with the payload casted to
> QObjects)
> does not seem to work. There's one, corrupt and therefore unusable entry in
> the returned data in the best case, no data at all in the worst.
>
> A workaround I've found is to send a list of QActions (.name()) in a
> QStringList to the runtime, and offer a Q_INVOKABLE QAction*
> action(QString);
> accessor which returns a QAction* to the runtime.
>
> Your button has the following:
>
> property QtObject action
>
> onClicked: action.trigger()
>
> Then, in your delegate, you retrieve the action via the key you get in your
> "listmodel":
>
> delegate: ActionButton {
>                 action: cpppluginthing.action(modelData)
> }
>
> Not the most beautiful thing in the world, but it seems to work at least.
> I'm
> of course open to better solutions.
> --
> sebas
>
> http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20121028/e3ca87fc/attachment.htm>
-------------- next part --------------
_______________________________________________
Plasma-devel mailing list
Plasma-devel at kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


More information about the kde-core-devel mailing list