[Development] QAction-like API for QML

Kevin Krammer kevin.krammer at kdab.com
Tue Dec 11 10:28:22 CET 2012


On Tuesday, 2012-12-11, Alan Alpert wrote:

> Action type:
> QtObject {
>     property string text
>     property url imageSource
>     property string shortcut
>     property bool checkable: false
>     property bool checked: false
>     signal triggered(bool checked)
> }
> 
> Note that it has no-where near as many properties as QAction. toolTip
> and whatsThis for example are very desktop centric so not needed
> anymore. Because it's not actually doing the rendering it doesn't need
> enabled, visible or font.

QAction doesn't do any rendering either but still has visble and enabled.

I've always used this to set the respective state on only one object (the 
action) and have all UI delegates (menu entry, toolbar buttons, etc) follow 
that automatically.

Obviously it is easier in QML where you can bind the enabled property of the 
menu entry, the toolbar button and the shortcut to the same custom property.

Do you have a specific use case in mind that would require to disable some 
trigger sources but not all?

Cheers,
Kevin
-- 
** Qt Developer Conference: http://qtconference.kdab.com/ **

Kevin Krammer | kevin.krammer at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4712 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121211/107a1cd0/attachment.bin>


More information about the Development mailing list