Qt World Summit: Submit your Presentation

Position window in linux

  • QT5.12.5 on fedora 30 x86-64.
    When I use the following code

    QPoint p = pos();
     move( p );

    my window moves vertically upwards by the width of the Window Manager's top border (which contains the title of my window). How can I get this width, so that I can compensate with the above move? When I run the same code on Windows 10, my window stays put, as desired.

  • The above move is superflous so don't do it. Simply hide and show without repositioning the window. window managers and decoractions make the kind of move you are trying ambiguous.

    If you must explicitly position the window then do move() before the initial show and always use that location, understanding that it won't be accurate (because the window manager decorations are not part of the wiget's geometry.

    This is the price you pay for a plethora of plug-in widow managers with different capabilities and styles.