if (!(state & Qt::MouseButtonMask)) { bool next_is_button_up = false; MSG msg1; if (PeekMessage(&msg1, msg.hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_NOREMOVE)) next_is_button_up = (msg1.message == WM_LBUTTONUP); if (! next_is_button_up) qt_button_down = 0; }