Recent

Author Topic: Window positioning in QT5  (Read 1574 times)

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Window positioning in QT5
« on: June 24, 2025, 05:48:21 pm »
I'm finishing up a program for Fedora Core, using QT5 widgets. All works well except that a couple of routines resize a form and move it to the right while displaying a new form to its left at position 1 (left:= 1). I have been fighting to get the windows to move for the better part of a day.  Resizing works fine, but moving the position of the form does not. The forms always open in the screen center, and cannot be moved programmatically.

I wrote a simple test to move a form around and it worked fine. Then I realized that I was using QT5 in the Fedora program. Changing that to stock GTK2 fixed the problem with moving forms around. I am using a Ryzen 7 laptop with 16 G of memory and 2 1TB ssd's. This is Laz 3.6 installed using fpcupdeluxe and has been running flawlessly for many months. This Laz install is running on Fedora 42.

To reproduce the problem, simply compile and run the attached test app. then change the widget set to gtk2 and run it again. Note that you need to have qt5pas installed.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8453
Re: Window positioning in QT5
« Reply #1 on: June 24, 2025, 10:07:40 pm »
Is your system X11 or Wayland?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Re: Window positioning in QT5
« Reply #2 on: June 24, 2025, 10:19:17 pm »
It's wayland, but I thought they had all of the form/window movement fixed. I'll try Xorg and see if it is wayland.

Thanks,
--- Jem

zeljko

  • Hero Member
  • *****
  • Posts: 1770
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Window positioning in QT5
« Reply #3 on: June 24, 2025, 10:27:20 pm »
You have problem with Qt5 because it uses wayland, and gtk2 uses x11 because it doesn't know anything about wayland.Start your app with -platform xcb and you're good to go :)

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Re: Window positioning in QT5
« Reply #4 on: June 25, 2025, 12:02:43 am »
I'm not familiar with that switch (-platform xcb). It causes an error on my system when I try to run the compiled program with it. is that a compiler command?

Thanks,
--- Jem

dbannon

  • Hero Member
  • *****
  • Posts: 3425
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Window positioning in QT5
« Reply #5 on: June 25, 2025, 07:37:21 am »
I'm not familiar with that switch (-platform xcb). It causes an error on my system when I try to run the compiled program with it. is that a compiler command?

No Jem, its a switch to your compiled application. Only works with a Qt5 (and Qt6 ??) application, should be ignored by a gk2 app. But your gtk2 app may object to an unexpected command line switch ?

Another possibility, I have been reading recently that Fedora has or will leave x11 out of its Gnome systems entirely, despite ample evidence Wayland is not ready yet, that probably means xcb too. Ubuntu doing the same thing apparently. They suggest (as I do) you use a more user friendly desktop, Mate, XFCe, etc instead of Gnome. Apparently KDE still has X11 support but for how long ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Re: Window positioning in QT5
« Reply #6 on: June 25, 2025, 09:25:42 am »
You were both right. Obviously I mis-typed something when I added that switch to the command line. It does correct the problem in QT5. Thanks to both of you guys, that's a switch I will remember.

--- Jem

PascalDragon

  • Hero Member
  • *****
  • Posts: 6051
  • Compiler Developer
Re: Window positioning in QT5
« Reply #7 on: June 25, 2025, 10:35:20 pm »
It's wayland, but I thought they had all of the form/window movement fixed. I'll try Xorg and see if it is wayland.

No, placement of windows in Wayland is simply not supported. There is a lengthy merge request for a potential extension, but even then it is mainly intended for positioning windows relative to one another (from the same application).

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Re: Window positioning in QT5
« Reply #8 on: June 27, 2025, 03:46:17 am »
Thanks, I was told that had been fixed. Why are distros running head on into waylands arms when it is simply not as robust as X? I don't understand the logic. I know it's the future because of a much cleaner code base, but it doesn't have to be the future today. Sorry for the rant.

--- Jem

MarkMLl

  • Hero Member
  • *****
  • Posts: 8453
Re: Window positioning in QT5
« Reply #9 on: June 27, 2025, 08:41:05 am »
Micro-rant entirely justified IMO. Only reason I raised the possibility was that a couple of days earlier I'd (elsewhere) seen something about programs being unable to restore their size at startup... or possibly the overall OS (i.e. including GUI management) being unable to do it on their behalf.

However a lot of this boils down to a poor (badly documented and patchily implemented) interface between the widget set and the Window Manager: I have in the past encountered a situation where a program misbehaved on an RPi because the WM didn't handle text metrics properly.

And then there's this... https://hackaday.com/2025/02/04/freedesktop-and-alpine-linux-looking-for-new-hosting/

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

HotShoe

  • Jr. Member
  • **
  • Posts: 56
Re: Window positioning in QT5
« Reply #10 on: June 27, 2025, 10:55:25 pm »
Thanks Mark, I didn't know that had happened. I wrote an article a few years back that brought me a lot of hate mail. The truth sometimes hurts, but I felt that someone needed to sat it out loud. I'll probably regret it, but here's a link. It is not for the faint of heart or true free software zealots.

https://www.perf-tek.com/linux.pdf

The question becomes: would you buy a copy of Lazarus for a reasonable price? Yes I would.

--- Jem

dbannon

  • Hero Member
  • *****
  • Posts: 3425
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Window positioning in QT5
« Reply #11 on: June 28, 2025, 02:20:58 am »
Thanks, I was told that had been fixed. Why are distros running head on into waylands arms when it is simply not as robust as X? I don't understand the logic. I know it's the future because of a much cleaner code base, but it doesn't have to be the future today. Sorry for the rant.

I believe (?) that the big multinationals have an interest in minimizing the transition time between X11 and Wayland. They don't (generally) use things like Fedora and Ubuntu (on important kit), they use 'safe' distros like RedHat. So, their best strategy is to suggest Wayland be widely adopted in the "peoples linuxes", the bugs ironed out and the developers familiar with the API. And, in projects like RedHat/Fedora, a 'suggestion' from the big guys carries a lot of weight.

As far as I can tell, its not exactly impossible to move a window under Wayland (except perhaps the main window), just massively harder. https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface-request-attach - I suspect it may involve compositor specific code and certainly require a better understanding of how Wayland works than most of us want to acquire.

I don't see projects like https://github.com/X11Libre/xserver being widely acceted because it wont have that big business support, like it or not, Linux is dependent on big business's investment.

Davo


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Fred vS

  • Hero Member
  • *****
  • Posts: 3629
    • StrumPract is the musicians best friend
Re: Window positioning in QT5
« Reply #12 on: June 28, 2025, 06:10:34 am »
I don't see projects like https://github.com/X11Libre/xserver being widely acceted because it wont have that big business support, like it or not, Linux is dependent on big business's investment.

Maybe or maybe not.

 ;)
« Last Edit: June 28, 2025, 06:13:23 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

MarkMLl

  • Hero Member
  • *****
  • Posts: 8453
Re: Window positioning in QT5
« Reply #13 on: June 28, 2025, 08:49:42 am »
As far as I can tell, its not exactly impossible to move a window under Wayland (except perhaps the main window), just massively harder. https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface-request-attach - I suspect it may involve compositor specific code and certainly require a better understanding of how Wayland works than most of us want to acquire.

In another thread, somebody says that getting PrintScreen to work has to be done using PipeWire and this might possibly also be applicable here. I've not followed it up but am getting increasingly concerned by the modern tendency to pile protocol atop protocol simply because one of them provides some facility that the current developer /must/ /have/: PipeWire for Wayland, MQ (IIRC, or something similar) for Home Assistant, WebSockets for the Myford AI assistant and so on. At least "back in the day" the intention of that was to improve the accessibility of the server since the protocol had support libraries in just about every language, but these days the choice of usable languages seems to have degenerated to one of C++/Java/Rust with Python intended to make it usable by mortals.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

dbannon

  • Hero Member
  • *****
  • Posts: 3425
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Window positioning in QT5
« Reply #14 on: June 28, 2025, 09:51:55 am »
XLibre ?
Maybe or maybe not.

OK Fred, some will (honestly, I hope all will). But if your Mum asks you to install Linux on her computer, would you choose [Arch,Artix, OpenMandriva, Vipnix]. Say you live 250Km away, its going to be something just a bit more mainstream ?

I am a bit unsure of what the tables there mean. For example, Ubuntu will not have "removed x11" from its repos ?  No, only from its flagsh*t, woops, flagship, Gnome distro. You can install Ubuntu Gnome then use apt to install XFCe, Mate etc that do need X11. So, it MUST still there in their repo. Just not present (nor can be used by) Gnome.  Don't forget, most packages in Ubuntu Repos, are imported from Debian with a name change.

Debian could well be a XLibre supporter some time in the future but they do move very slowly. If they do, they would drag Ubuntu along, kicking and screaming ...

Fred, I hope so, Wayland is designed to be harder, bigger, less functional. We don't need it. But the big guys (apparently) do.

Davo
 

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018