Solved simulating mouse area release event.
-
hi all,
anyone know how to simulate a mouse release event , jut like imitating qt mouse area release event.
i have a scenario where one button item stuck in pressed state. i want to send a simulated mouse area released event for this button.
thanks,
ayyappa. -
You can use QTest library for this: https://doc.qt.io/qt-5/qtest.html#mouseRelease
Or construct a QMouseEvent yourself and pass it to the event loop.
But, if your button is stuck, I'd rather say you should fix that.
-
@sierdzio said in simulating mouse area release event.:
onstruct a QMouseEvent yourself and pass it to the event loop.
thanks for your input. i will try fixing it in code without having to simulate mouse release events.i will also look into QTest library and update the topic accordingly.
actually this button struck case occurs in following scenario:
i have a soft keyboard item which contains many keys(buttons) in it.
if i press a button(first) with finger(touch) , and with out releasing this button, if i click on different button(second) with mouse, second button click executed successfully,but even after taking finger off the first button i pressed , first button stayed in pressed state.could you please suggest any approach that you think that could solve this issue?.
thanks,
ayyappa. -
Whoa, that's an unusual use case. I have no idea how to help here, sorry. It sounds a bit like a bug in Qt (so perhaps report it?) and a bit like a corner case that might be intentionally left unimplemented.
Perhaps MultiPointTouchArea could help? https://doc.qt.io/qt-5/qml-qtquick-multipointtoucharea.html It's a total guess, though.
-
@AYYAPPA have you already brought this to the Qt Bug Tracker system ?
Seems like something that should not happen, but seems like a fringe case as well.
The assignee may, at the very least - have an idea on how to deal with that. -
@sierdzio
hi,i tried using multitouchpointarea in place of mousearea, and used mouseEnabled= true, it worked.This issue is not happening anymore. it treats both touch and mouse independently and it is an acceptable result for our product. thank you very much for your suggestion.
MultiPointTouchArea {
anchors.fill: parent
maximumTouchPoints: 1
mouseEnabled: true
onpressed
{ //do something...}
onreleased
{//do something....}
}It would have been better if this was handled by Qt itself, as i had some other functionalities i was making use from mouse area like DoubleClicked, hovered(entered, exited) which are not avaliable in multitouchpont area. I will investigate how to use both multitouchpointarea and mousearea together. but for now i am glad that the major issue is resolved.
-
@J.Hilk i haven't raised a bug in Qt Bug Tracker system yet, i will do that as per your suggestion.thank you.
-
@AYYAPPA
great make sure to link the case so others can check/find the bug report as well -
i have raised a bug for this in Qt bug reporting system,
https://bugreports.qt.io/browse/QTBUG-75196