Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.6.0
-
None
-
Ubuntu 14.04.4LTS
-
571f4be253386cb30a55060bed7d81ef356124eb
Description
With the stable, non-labs version of qabstractbutton.cpp, clicking a button results into its state being updated with nextCheckState(), then the released() and clicked() signals emitted:
void QAbstractButtonPrivate::click() { // ... QPointer<QAbstractButton> guard(q); if (changeState) { q->nextCheckState(); if (!guard) return; } // ... if (guard) emitReleased(); if (guard) emitClicked(); }
Good. Now, with the new, labs version of qquickabstractbutton.cpp, the opposite is done: first the released() and clicked() signals are emitted, then the button state is updated with nextCheckState():
void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event) { // ... if (wasPressed) { emit released(); emit clicked(); } else { emit canceled(); } if (contains(event->pos())) nextCheckState(); // ... }
This means getting the state in an onClicked handler will present me the old, unchanged state. To me this looks like a serious regression:
- This is a breaking change from QtQuick controls 1.
- It seems to me that client code relying on onClicked likely wants to work with the new state resulting from the click, not the old one. Wrong?
- Not an argument per se but incidentally, emitting the event at the very end and exposing the new state is the model used by JS events on the web, to which many developers are used to.
- Thinking it was maybe intentional, I tried to use the new behavior. In my case I was working on moving checkboxes (which inherit from Q(Quick)AbstractButton) from qtquick1 to qtquick2. So I moved my handlers from onClick to onCheckedChanged.
- But then, that means I can no longer set checked directly or I have a binding loop.
- Alright, let's rather Component.onCompleted: {checked = "...";}
- But then at startup, checked is changed, calling checkChanged, and negating the initial state of my checkboxes :-/
→ Am I missing something? Is this change intentional? If yes, what would be the proper way to do initialization and event handling for my checkboxes?
Attachments
Issue Links
- is duplicated by
-
QTBUG-57607 There's no way to get if a button was toggled by user or by setting checked property
- Closed
-
QTBUG-52558 Behavioral incompatibility between QQuick* checkables and QWidget/Quick.Controls checkables
- Closed
For Gerrit Dashboard: QTBUG-52448 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
155440,2 | QQuickAbstractButton: fix the order of nextCheckState() vs. clicked() | 5.7 | qt/qtquickcontrols2 | Status: MERGED | +2 | 0 |