Important: Please read the Qt Code of Conduct -

Qt 4.7.0 & Ubuntu 10.10: Cannot move application window out of desktop bounds

  • Create a simple application and instantiate a QWidget to create a simple window. Move the widget inside the code to (-50, -50), let one of the coordinates be negative.
    The result is that the window is positioned at (0, 0) instead of the requested position. This is observed using Linux (Ubuntu 10.10) and Qt 4.7.0.
    This problem is not reproduced under Windows and Mac OS X.

    So, the question is how to move the application window out of the desktop bounds inside the code under Linux?

    Additional notes:
    It is the window manager that constrains the application windows to leave the desktop area.

    1. The application window can be partially moved out of the desktop by dragging it through the titlebar. In this case the titlebar is the only part of the application window that cannot leave the desktop area towards the Y axis of the screen.
    2. Hitting alt + left mouse button click (anywhere in the application window area) and dragging the mouse produces the desired effect - the window manager grabs the window and moves it out of the desktop bounds. How to achieve this effect inside the code?

  • Does this happen with non-Qt applications too? The default on Kubuntu is to maximise windows when attempting to move them out of the screen space. This behaviour can be changed in the systemsettings.

  • Try the following:

    1. Open an application of your choice - Firefox for example.
    2. There are two ways to move it:
      a) User actions:
      Move the application window by grabbing the title bar with the mouse button and begin dragging it in both directions:
      -> horizontally: the whole application window can be moved outside the desktop boundaries
      -> vertically: the application window can be moved outside the desktop bounds but the title bar cannot
      b) Programmatically:
      -> use the QWidget::move function to move the widget to negative coordinates. This way it is not possible to move any of the application window parts out of the desktop - neither the client area of the application window nor the title bar.

    The whole problem originates from the window manager and the substructure redirection feature, I think. Alt + Left Mouse Button drag is a window manager's feature. It is not controlled by the application.

    QWidget::setWindowFlags( Qt::X11BypassWindowManagerHint );
    … is one way to prevent the application window from being managed by the window manager.
    QWidget::setAttribute( Qt::WA_X11NetWmWindowTypeDock );


    QWidget::setAttribute( Qt::WA_X11NetWmWindowTypePopupMenu );

    … is another way to be able to move the window out of the desktop bounds and again the application window becomes unmanaged by the window manager. This is not desired.

    I am currently looking forward to moving the window programmatically out of the desktop boundaries. This is not possible by just using QWidget::move(). This inability to move the window out of the desktop bounds happens even to non-Qt applications in Ubuntu. Currently, I am looking into the xlib to achieve this effect.

    Probably xlib should be used and some window flags of the application window should be set. I am not seeing any ways to do this by Qt means.

  • Hi napajejenunedk,

    Did get the solution at the end? I'm facing exactly the same problem. Turns out that disabling the window management you lose all other capabalities such as minimize and keyboard focus, as documented in Qt documentation.

    Maybe removing the window management during the drag options and enabling again (but this would genarating some flickering).

    ...still, not desired.

Log in to reply