I display the push flow information of OBS on the QMainWindow object. When I change the size of the QMainWindow window by dragging with the mouse, the window flickers; when I drag the mouse (without changing its size), the window does not flicker. I checked the message through spy++ and found that when I change the window to flash, the system will generate a WM_PAINT message. as fllow enter image description here By looking at Qt's help documentation, I rewrote the function nativeEvent; however, when I judge the WM_PAINT, WM_ERASEBKGND message, the program will fall into an infinite loop
bool MainLayerItemWndView::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
MSG* msg = (MSG*)message;
switch (msg->message)
{
case WM_PAINT:
std::cout << "nativeEvent paint: " << "message handle1:" << std::endl;
*result = 1;
return true;
break;
case WM_ERASEBKGND:
*result = 1;
std::cout << "WM_ERASEBKGND :---------------" << std::endl;
return true;
break;
default:
break;
}
return QWidget::nativeEvent(eventType, message, result);
}