Solved popup modal dialog does not have focus on touch screen
-
@Pl45m4 Thanks for your reply. Right, I have to click mouse once(focus+button click at once), twice with finger on the touch screen. I will check the QTouchEvents out.
-
-
@jsulm I did. I moved them out. They were not there before. I still think it is a focus problem since all buttons work fine when pressed on the main window.
-
@Pl45m4 said in popup modal dialog does not have focus on touch screen:
A tap on screen will trigger QTouchEvents and not QMouseEvents directly. There could be something wrong...
Have you checked the result of the
QTouchEvent
?
IfRaise
,Focus
and so on are connected to the QMouseEvent and not to theQTouchEvent
directly, maybe you have to emit or trigger some signals / events to have the same effect on finger tap as on mouse click. -
In order to receive QTouchEvent, the button widget has to have attribute Qt::WA_AcceptTouchEvents. It is set and QTouchEvent can be received. Event filter is added to the buttons and dialog for QTouchEvent. Now one press on the touch screen activates one button. It works now. Thanks a lot for your tip.
However, the touch event can be received only for the dialog, but the buttons when the exact code is used to pop up the dialog from another main window.
I still think the focus is the root cause. The pop-up dialog simply can not get the focus. -
@Pl45m4 A tap on screen does trigger QEvent::MouseButtonPress. That is why all other buttons on the main window work fine.
-
Still have not figured out how to let the pop-up dialog get focus. Any help?
-
Hi
I would try without the line
setWindowFlags((Qt::WindowFlags)(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
and see if still the same.Also, i would qDebug()
QWidget *QApplication::focusWidget()
to see who got the focus then.What platform is this on ?
-
@mrjj It is on Ubuntu. The flag settings are as follows:
setWindowFlags((Qt::WindowFlags)(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint));
I checked the focus widget which is on a button inside the main widget. The problem is why the pop-up dialog or its children can not get focus? -
Did you solve this problem, @JoeCFD ? I am having the same problem and starting to be a bit desperated. Thanks to all in advance.
-
Add event filter and handle press event. Then check event position and you know which button is clicked.
-
@JoeCFD Not yet.Did you solve it?
-
@JoeCFD , @swansorter, I finally figured out what whas happening in my case. Since my touch screen is a capacitive one, I had to create my qdialog on mousereleaseevent, instead of on mousepressevent.