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

List:       kde-panel-devel
Subject:    QActions in QML
From:       Sebastian =?ISO-8859-1?Q?K=FCgler?= <sebas () kde ! org>
Date:       2012-10-28 22:54:16
Message-ID: 10730993.Gxcz4dhZJS () marvin
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

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