Inadvertently found a bug,qt5.1.1 official version of
First create a GUI project and drag into a Qaxwidget control (for ActiveX to take effect, you need to add config + = Qaxcontainer in the. Pro file)
Next, in order for ActiveX to work, you need to introduce a component that I introduced here is the IE component
[CPP]View PlainCopy
- Mainwindow::mainwindow (Qwidget *parent):
- Qmainwindow (parent),
- UI (new Ui::mainwindow)
- {
- UI->SETUPUI (this);
- Ui->axwidget->setcontrol ("{8856F961-340A-11D0-A96B-00C04FD705A2}");
- }
Then you can start the test, generate EXE, run, the window is OK
The mouse clicks on the taskbar window, and the window is minimized, click Restore again, and change to this
Obviously, the window does not receive a drawing message when it is re-displayed, only the part of the ActiveX is displayed properly.
After an afternoon of debugging, the Discovery window did not receive the WM_PAINT message after receiving the wm_activate message
and normally it should be this order: wm_activate > WM_PAINT
The introduction of ActiveX after WM_PAINT is gone, this is the cause of the problem!
Knowing the cause of the problem is good, just forcing the window to redraw.
Overriding the Nativeevent method of the parent class in order to process Windows messages
[CPP]View PlainCopy
- BOOL Mainwindow::nativeevent (const qbytearray &eventtype, void *message, long *result)
- {
- PMSG msg = (PMSG) message;
- if (msg->message = = Wm_activate && Msg->wparam = = wa_active)
- {
- //window is activated, Force redraw
- InvalidateRect (HWND)This->winid (), nullptr, FALSE);
- }
- return false;
- }
The fix is this bug:
https://bugreports.qt.io/browse/QTBUG-17548
http://blog.csdn.net/aqtata/article/details/17038105
A bug with ActiveX components in the "Qt" borderless form