Problems when changing the flags of a QWidget

  • Hi guys.
    I have a QWidget as the child of another within my application. The task consists of putting the internal widget in full screen mode and being able to see it again in normal mode with the same button. This partly I have managed to do it in the following way:

    setWindowFlags(windowFlags() | Qt::Window);
    setWindowFlags(windowFlags() & ~Qt::Window);

    The problem arises when you return to see the widget in normal mode. Things that happen:

    • The mouse cursor stays with pointing hand cursor.

    • The button to change mode remains in hover state (the background color is changed when the mouse is over)

    • Passing the mouse through other widget controls does not change its appearance

    I have to click on the widget to fix the behavior. It's as if the widget did not receive events of any kind or something like that. I tried calling setFocus () and it did not work. I have also tried to send an event by hand in the following way but it has not worked either:

    QMouseEvent my_event(QEvent::MouseButtonPress, QPointF (0, 0), Qt :: NoButton, 0, 0);
    QApplication::sendEvent(this, & my_event);

    Any ideas?


  • Qt Champions 2017

    You are just sending the mouse Press event.
    You never send the mouse Release event so it thinks its still pressed. :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.