[Development] 回复: QPushButton: drag and drop

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Jun 6 15:15:13 CEST 2022


On 06/06/2022 10:49, Zhang JiDe wrote:
> I agree that we should fix this, but it's not as simple as passing the 
> mouseReleaseEvent to the QPushButton, but we should make sure that for a 
> QWidget, whatever happens, the mouse press and release are paired, 
> always notify the mouse release to the QWidget of pressed target. If 
> adding a new event to it will make things complicated, I suggest adding 
> a new item for MouseEventSource, such as: MouseEventSynthesizedByUngrab, 
> which is like to XCB_NOTIFY_MODE_UNGRAB, judge the source of QMouseEvent 
> in QPushButton, if it is MouseEventSynthesizedByUngrab, do not trigger 
> clieck, and update the UI.

Well, whether it's a new event or a new "option" for an existing event, 
this would still require modifications to pretty much every widget class 
-- e.g. QPushButton would need to check the release event source in its 
mouseReleaseEvent, to decide what to do?

I still like an event-driven approach, because I still hope one day that 
we can kill all the blocking exec() methods in Qt, and QDrag::exec() is 
one of the hardest to get rid of (and one for which we still don't have 
a solution in the API).

My 2 c,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20220606/35bb8fb9/attachment.bin>


More information about the Development mailing list