[Development] QAction-like API for QML

Alan Alpert 416365416c at gmail.com
Tue Dec 18 18:39:49 CET 2012


With all the discussion about the C++ API and the C++ compatibility
let me clarify that it is a different topic to the QML API. They're
both important topics and I'd like to see both implemented perfectly,
but they are separate topics with potentially separate
implementations.

The exposed QML API can be implemented in a variety of ways from C++,
and this does not matter to QML. A completely different C++ type can
implement the same QML type and no-one will notice the difference -
you can even do that in a minor version if you're careful. The worst
case is that the type checking goes from compile-time to run-time for
some properties.

I agree that it's ideal to resolve these related topics at the same
time, but it's not essential. Hypothetically assume the QML API is
trivial to implement and the C++ API takes years, in that situation
you can still implement the QML API now and when the C++ API is ready
it just slides in and you're still at the ideal solution and the ideal
set of exposed APIs. Moving away from the hypothetical situation, in
this case it's probable that it would be both efficient and possible
to implement the C++ and QML APIs at the same time. Still doesn't mean
we have to. So please let us approach this as two separate issues,
both important, and without feeling like the C++ side is being
neglected in favor of QML-only applications.

So the unresolved questions that I see for the 'QAction-like API for QML' topic.

Used like Jens suggested for components:
> RowLayout { Repeater { model: myActions ; ToolButton { action: modelData} }
> }}
>
> Granted, a bit too verbose. However with a little bit of convenience, we can
> for instance reduce this to just:  ActionRowLayout { model: myActions }

Given this approach do we need the ActionGroup type? Are
exclusive/collapsible needed now?

Also given the shortcut discussion are Actions sufficient for
launching shortcuts or should a simple Shortcut{} be added too?

I'm of the opinion that Shortcut{} is just confusing, it adds the
cognitive load of having a choice on how to implement a shortcut for
no good reason.

On Tue, Dec 18, 2012 at 4:00 AM, Stephen Kelly <stephen.kelly at kdab.com> wrote:
> On Tuesday, December 18, 2012 12:55:50 Stephen Kelly wrote:
>> Some of this came up before by the way, so it's another discussion to
>> review  when designing this:
>>
>>  http://thread.gmane.org/gmane.comp.lib.qt.devel/957/focus=1883
>
> Another funny thread from almost a full year ago:
>
> http://thread.gmane.org/gmane.comp.lib.qt.devel/1093/focus=1180

He brings up a good point, QtQuick doesn't need an Action type. But it
has to go somewhere, so either it goes in QtQuick for use as a
'graphical-related primitive', QtQml, or QtWidgetEnablers (if it still
has the widgets dependency).

--
Alan Alpert



More information about the Development mailing list