[Solved][Android] [Qt 5.2] Popup dialog doesn't close with touch/click
-
Hi
In my android tool made with Qt I would like to use some popup dialog. Testing the code under Windows it work very well. The popup show up and if I click in some area of the window outside the popup area the popup close automatically itself as expected. Same behaviour doesn't happen in android (emulator) where the popup stay visible and there is not way to close itself by touching around.
Someone can help?
Thank you
-
Hi,
Which Popup Dialog have you used ?
Try using "Menu":http://qt-project.org/doc/qt-5.1/qtquickcontrols/qml-qtquick-controls1-menu.html if it fits your requirement.
It works perfectly as per your description on android. -
Hi
Thank you for your reply. I created a QDialog with the popup window flag (I develop from C++ side, not QML). This dialog show as square with shadow and correctly disappear when I click in area outside it. Same behaviour doesn't happen under android. I can know android architecture is different since, I guess, the OS is basically a single window interface but I need to find a way for detect a click/touch outside my dialog. This for detect when close it. Unfortunately grab mouse function is not suppotred in android...
-
Hi,
Check if closeEvent() is getting called.
I tested the same on Qt 5.2.1 and the Dialog with Popup flag opens and closes as expected. -
Hi
Thank you for your help. I'll try to check the event you suggested. Just for know do you start your popup dialog using exec()? I show the popup dialog in modal mode since I need to stop the code until the popup will close but if this is not the right way for have pupop working on android I'll can find a workaround for my code...
-
Just made the test. The event closeEvent() was not called if I click/touch outside the popup dialog and, in consequence, the popup dialog was not closed.
-
Very happy to discover the problem came from the use of exec(). I just made the test and using show() instead of exec() the popup dialog show and automatically close as expected. Thank you for your suggestion, it helped me a lot. :)
-
That's great. I had used show() for displaying it :). But exec() should also work similar. Now since you have mentioned that you have to stop the control until the popup dialog closes you can emit signal from the closeEvent of the dialog to the parent and in the corresponding slot in parent you can execute the next code.
-
it seem exec() work under Windows only. I suspect the problem came from the window management of android that is basically a single window mode. On the contrary Windows is a multi windows mode than can manage event outside a modal dialog (I suppose). About simulate the stop I already found a working solution. I put a cicle after the show() looping the call to QCoreApplication::processEvents() until close event is received. Is not very elegant but it work, just tested!
-
I'm not sure if it is due to single window mode. It works perfectly on Linux too.