[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: QActions in QML
From:       Daker Fernandes Pinheiro <dakerfp () gmail ! com>
Date:       2012-10-29 0:33:55
Message-ID: CAHhpqga0a64Mmmdn0XeL_TOgOxndVQETSODRw1UjVg-p=8-9wA () mail ! gmail ! com
[Download RAW message or body]

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=C3=BCgler <sebas@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 yo=
ur
> "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@kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>

[Attachment #3 (text/html)]

Sebas,<div><br></div><div>This just worked:</div><div><a \
href="http://paste.kde.org/584660/">http://paste.kde.org/584660/</a></div><div>Where \
QAction is</div><div><a \
href="http://paste.kde.org/584672/">http://paste.kde.org/584672/</a></div>

<div><br></div><div>Cheers,</div><div><br clear="all">Daker Fernandes Pinheiro<br><a \
href="http://codecereal.blogspot.com" \
target="_blank">http://codecereal.blogspot.com</a><br><br><br><div \
class="gmail_quote">2012/10/28 Sebastian Kügler <span dir="ltr">&lt;<a \
href="mailto:sebas@kde.org" target="_blank">sebas@kde.org</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">On Thursday, October 25, 2012 20:00:25 Aaron J. Seigo \
wrote:<br> &gt; not automatically, no. but QActions are QObjects, so you can attach \
to their<br> &gt; signals in the QML.<br>
<br>
And it&#39;s quite wonky, for example offering a list of QActions<br>
(QDeclarativeListProperty or QList, even with the payload casted to QObjects)<br>
does not seem to work. There&#39;s one, corrupt and therefore unusable entry in<br>
the returned data in the best case, no data at all in the worst.<br>
<br>
A workaround I&#39;ve found is to send a list of QActions (.name()) in a<br>
QStringList to the runtime, and offer a Q_INVOKABLE QAction* 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 your<br>
&quot;listmodel&quot;:<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. I&#39;m<br>
of course open to better solutions.<br>
<span class="HOEnZb"><font color="#888888">--<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> \
</font></span></blockquote></div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic