2012/10/28 Aleix Pol <span dir="ltr"><<a href="mailto:aleixpol@kde.org" target="_blank">aleixpol@kde.org</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Mon, Oct 29, 2012 at 1:33 AM, Daker Fernandes Pinheiro<br>
<<a href="mailto:dakerfp@gmail.com">dakerfp@gmail.com</a>> wrote:<br>
> Sebas,<br>
><br>
> This just worked:<br>
> <a href="http://paste.kde.org/584660/" target="_blank">http://paste.kde.org/584660/</a><br>
> Where QAction is<br>
> <a href="http://paste.kde.org/584672/" target="_blank">http://paste.kde.org/584672/</a><br>
><br>
> Cheers,<br>
><br>
> Daker Fernandes Pinheiro<br>
> <a href="http://codecereal.blogspot.com" target="_blank">http://codecereal.blogspot.com</a><br>
><br>
><br>
> 2012/10/28 Sebastian Kügler <<a href="mailto:sebas@kde.org">sebas@kde.org</a>><br>
>><br>
>> On Thursday, October 25, 2012 20:00:25 Aaron J. Seigo wrote:<br>
>> > not automatically, no. but QActions are QObjects, so you can attach to<br>
>> > their<br>
>> > signals in the QML.<br>
>><br>
>> And it's quite wonky, for example offering a list of QActions<br>
>> (QDeclarativeListProperty or QList, even with the payload casted to<br>
>> QObjects)<br>
>> does not seem to work. There's one, corrupt and therefore unusable entry<br>
>> in<br>
>> the returned data in the best case, no data at all in the worst.<br>
>><br>
>> A workaround I've found is to send a list of QActions (.name()) in a<br>
>> QStringList to the runtime, and offer a Q_INVOKABLE QAction*<br>
>> action(QString);<br>
>> accessor which returns a QAction* to the runtime.<br>
>><br>
>> Your button has the following:<br>
>><br>
>> property QtObject action<br>
>><br>
>> onClicked: action.trigger()<br>
>><br>
>> Then, in your delegate, you retrieve the action via the key you get in<br>
>> your<br>
>> "listmodel":<br>
>><br>
>> delegate: ActionButton {<br>
>> action: cpppluginthing.action(modelData)<br>
>> }<br>
>><br>
>> Not the most beautiful thing in the world, but it seems to work at least.<br>
>> I'm<br>
>> of course open to better solutions.<br>
>> --<br>
>> sebas<br>
>><br>
>> <a href="http://www.kde.org" target="_blank">http://www.kde.org</a> | <a href="http://vizZzion.org" target="_blank">http://vizZzion.org</a> | GPG Key ID: 9119 0EF9<br>
>> _______________________________________________<br>
>> Plasma-devel mailing list<br>
>> <a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
>> <a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Plasma-devel mailing list<br>
> <a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
> <a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
><br>
<br>
</div></div>Wouldn't it be better to qmlRegisterType<QAction> directly?<br></blockquote><div><br>That's definetely true.<br>I got this snippet from another project and it re-implemented trigger.<br>But that's not the case.<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Aleix<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Plasma-devel mailing list<br>
<a href="mailto:Plasma-devel@kde.org">Plasma-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/plasma-devel" target="_blank">https://mail.kde.org/mailman/listinfo/plasma-devel</a><br>
</div></div></blockquote></div><br><br>Br,<br><br>Daker Fernandes Pinheiro<br><a href="http://codecereal.blogspot.com" target="_blank">http://codecereal.blogspot.com</a><br><br>