[Development] Application wide shortcuts API for QML

Alan Alpert 416365416c at gmail.com
Tue Dec 11 17:12:02 CET 2012


On Tue, Dec 11, 2012 at 12:53 AM, Mark <markg85 at gmail.com> wrote:
> Hi,
>
> Alan' posts about possible future APIs made me want to post this as
> well. In the QWidget works we have the rather nice QShortcut class to
> aid us in defining application wide shortcuts.
>
> Functionality like that is completely missing from the current QtQuick
> in both Qt 4.8 (1.1) and 5.0 (2.0). For desktop based applications an
> API like that would be very much needed since applications need to
> have the ability to define app wide shortcuts.

Known issue. In fact, someone already started work on this:
https://codereview.qt-project.org/#change,41816

> I already made an API for exactly this reason which can be found here [1].
>
> The API itself should look somewhat like this:
>
> Shortcut {
>     QKeySequence key
>     signal activated
> }

QKeySequence isn't available as a type to QML. Did you mean a string
property for key, which would be converted to a QKeySequence?

It wasn't explained well in the Actions API thread, but the thought
was that this could be initially exposed with the Actions API. The
string shortcut property there would be registered as an application
global shortcut, so you could use Actions separate from any menus to
do this. What do you think of having it just in the action API, or do
you think it needs its own item?

> Obviously if this is going to happen then mouse shortcuts should be
> included as well. Right now Qt itself has no possibility of defining a
> shortcut like "CTRL + LEFT MOUSE BUTTON" (or i don't know of it's
> possibility).

I agree that functionality would be nice to see for shortcuts in Qt.
But it's probably a separate issue, distinct from exposing the current
functionality to QML (which is a logical first step).

--
Alan Alpert



More information about the Development mailing list