A bug with ActiveX components in the "Qt" borderless form

Source: Internet
Author: User

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 
    1. Mainwindow::mainwindow (Qwidget *parent):
    2. Qmainwindow (parent),
    3. UI (new Ui::mainwindow)
    4. {
    5. UI->SETUPUI (this);
    6. Ui->axwidget->setcontrol ("{8856F961-340A-11D0-A96B-00C04FD705A2}");
    7. }

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 
  1. BOOL Mainwindow::nativeevent (const qbytearray &eventtype, void *message, long *result)
  2. {
  3. PMSG msg = (PMSG) message;
  4. if (msg->message = = Wm_activate && Msg->wparam = = wa_active)
  5. {
  6. //window is activated, Force redraw
  7. InvalidateRect (HWND)This->winid (), nullptr, FALSE);
  8. }
  9. return false;
  10. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.