PDA

View Full Version : Modal QDialog events 'stall' until window is moved



TuffLove
11th May 2017, 19:56
I'm using Qt 5.6.1 on Windows. I'm using it in a VST plugin. The host calls me, passing an HWND, and I use qtwinmigrate to turn that into a QWinWidget. I then stick my UI into that window by setting it as its parent...


mWidget = new QWinWidget(static_cast<HWND>(ptr));

mEditor->setParent(mWidget);
mEditor->move(0, 0);
mEditor->show();

mWidget->move(0, 0);
mWidget->show();


This has been working fine for years. Still works. But, something strange has happened since upgrading to Qt 5.6.

One of the buttons in my Qt ui opens a modal dialog box. There is nothing special about this dialog box... a few text fields, a few check boxes, and obviously (given that it is modal) it has OK and Cancel buttons.

The issue is this... that modal dialog box does not respond to any events. Click on an edit field to give it the focus, click on a checkbox, nothing. Even click the window close button at the top right corner of the window... nothing.

BUT... Click in the window drag bar and like magic... all of those messages get processed. Like they are all queued up someplace.

So, for example, if I click in an edit field, press the backspace key twice, and then click a blank checkbox, I see nothing change. But if I click in the window's drag bar... poof... I see the new value in the edit field and the new value in the checkbox.

If I click the OK button... nothing... but if I then drag the window it closes out from under me and my code picks right up after the call to the dialog box's exec call. As if I had just pressed the OK button.

Anyone have any ideas?

Oh... and again... all of this same code worked fine prior to our update from 4.8 to 5.6.1

Thanks

high_flyer
12th May 2017, 12:42
Oh... and again... all of this same code worked fine prior to our update from 4.8 to 5.6.1
Could be a Qt bug if you code didn't change.

Is there a reason you are bound to 5.6.1 and can't try a newer version?
(If it is a Qt bug, it might have been resolved since then)

TuffLove
15th May 2017, 19:37
OK. I fixed the issue. It may point to a Qt bug, or a documentation issue.

Again, in my situation I am hosting a QWidget in a VST plugin... so the host is NOT Qt. My system needs to be "polled" often to do various things. We handle this by creating a simple little class we call Poller, which is derived from QObject. The Poller, in its constructor, starts a timer. In the timer callback we call our system poll functions. In our DllMain function, we instantiate one of these Pollers.

OK... so... we have always started the timer with an argument of 0. The docs say...


A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

Again this always worked in the past.

So now that we are using 5.6, setting the timer to 0 gives the bad behavior described above, but setting it to 1 makes everything work again.