2012/10/28 Aleix Pol <aleix...@kde.org> > On Mon, Oct 29, 2012 at 1:33 AM, Daker Fernandes Pinheiro > <dake...@gmail.com> wrote: > > 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 <se...@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@kde.org > >> https://mail.kde.org/mailman/listinfo/plasma-devel > > > > > > > > _______________________________________________ > > Plasma-devel mailing list > > Plasma-devel@kde.org > > https://mail.kde.org/mailman/listinfo/plasma-devel > > > > Wouldn't it be better to qmlRegisterType<QAction> directly? >
That's definetely true. I got this snippet from another project and it re-implemented trigger. But that's not the case. > > Aleix > _______________________________________________ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel > Br, Daker Fernandes Pinheiro http://codecereal.blogspot.com
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel