[Development] Move QAction from QtWidgets to QtGui

André Somers andre at familiesomers.nl
Tue Jul 3 15:38:50 CEST 2012


Op 3-7-2012 15:07, Shawn Rutledge schreef:
> On Tuesday wk27 2012 July 03 09:36:26 AM ext Anselmo L. S. Melo wrote:
>> Hi,
>>
>> On 07/03/2012 05:06 AM, Davide Bettio wrote:
>>> Hello,
>>>
>>> I've noticed that QAction hasn't been moved from QtWidgets module to
>>> QtGui module, it would be really good if also that module gets moved
>>> there.
>>> QAction require QWidget for few things but I think that it is possible
>>> to solve this problem easily.
> How would you suggest solving it?  QAction does have stuff like
>
>      bool showStatusText(QWidget *widget=0);
>      QWidget *parentWidget() const;
>      QList<QWidget *> associatedWidgets() const;
>      friend class QWidget;
>
> so it seems difficult to make it avoid depending on widgets without breaking
> API compatibility, which is why I figured we would need a separate Qt Quick
> action class.  Do you have any better ideas?
Would it not be possible to split QAction in two classes, just like 
QApplication was split? We could perhaps create a QCoreAction, that has 
no GUI dependencies at all but just has the core functionality: 
representing an action, a way to trigger that action, and the state of 
that action. Things dependent on QtWidgets could stay in QAction itself, 
which would probably subclass QCoreAction. QAction would stay in 
QtWidgets, but QCoreAction could live in QtGui or even QtCore.

Having an action class that is independent of GUI-like things like icons 
would be great to have for C++ as well. It makes it less awkward to use 
Q(Core)Action's in business-layer objects to expose functionality. The 
GUI layer could simply wrap these actions then and only add the 
GUI-dependent properties like icons.
>
> If we could somehow use the same class for both, maybe it would be possible to
> build UIs partially in Qt Quick and partially with widgets.
>
>> It was discussed a few months ago, but at that time the decision was to not
>> move QAction to QtGui. Unless this position has changed (as example of what
>> happened to QIcon), there is a version of QAction without the QWidget
>> dependency, in UiHelpers (http://qt-project.org/wiki/Qt-5-Ui-Helpers). The
>> destiny of this "new version" still not defined.
>>
>> Last week, Shawn Rutledge sent an e-mail to the qt-components list about
>> updating this stripped version of QAction so it could be used by the
>> desktop components. I think it's a good idea to check the status with him.
> Yes I was still thinking of merging the one from UiHelpers, with some
> improvements, and then working on making it useful in Desktop Components.
> (But instead I've been working on multipoint-touch support some more, the last
> couple of days.)  The open issues I can think of are
>
> * it needs to be possible to specify an icon with some kind of QML syntax
> (different pixmaps for different sizes)
Sounds like you need a QML-equivalent for QIcon?

André




More information about the Development mailing list