Recent

Author Topic: GTK or QT?  (Read 12304 times)

bitman

  • Newbie
  • Posts: 5
GTK or QT?
« on: September 04, 2021, 07:36:48 am »
Hi everyone, I'm new to the forum and to Lazarus in general, though I've got some experience with Pascal and Delphi.

I need to develop an app that needs to run on Linux, Windows and mac.  I will be developing solely on Linux, and my plan is to just recompile on Windows and mac later on.

I noticed that Lazarus on Linux works under the hood using either Gtk2 or QT. As a matter of fact, I think I installed the QT implementation in a Debian/KDE machine, while on another system with Solus/Budgie I believe I installed the Gtk version.

So, my question is: which one should I use (GTK or QT) so that it gives me the less problems later on when I try to recompile for Windows and Mac ??? Or doesn't make any difference? Should I just install the version that merely corresponds to the linux desktop I'm using at the moment (Plasma or budgie)?

Thanks in advance!

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: GTK or QT?
« Reply #1 on: September 04, 2021, 09:30:55 am »
I can't really speak for the Windows/Mac side of things, but my experience on Linux (mainly Debian) is that there are few issues compiling for /both/ GTK2 and Qt. Where you /do/ come across problems, e.g. if you're trying to do fancy stuff with keycodes or define control placement better than can be managed with anchors etc., I think I'd argue that if you isolate them early by regularly checking with multiple widget sets on the same platform then it will likely save you work when you migrate to a different one.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: GTK or QT?
« Reply #2 on: September 04, 2021, 09:34:29 am »
I'm using Qt on Linux, Windows and Mac for years and it suits all my needs. You must decide on your own what is better on Linux for you, gtk2 is usually installed by default, but gtk2 won't be default installation for so long time since it's pretty old lib now. Gtk3 widgetset isn't finished, on the other side we have Qt and Qt5 WS - stable and continuosly developed and maintaned. My recommendation is definitelly Qt5 if you start fresh project and need stable WS since all distros now pack libQt5Pas C library which is needed by Qt5 WS.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: GTK or QT?
« Reply #3 on: September 05, 2021, 11:34:56 am »
So, my question is: which one should I use (GTK or QT) so that it gives me the less problems later on when I try to recompile for Windows and Mac ??? Or doesn't make any difference? Should I just install the version that merely corresponds to the linux desktop I'm using at the moment (Plasma or budgie)?

For Windows and macOS neither Gtk nor Qt are used (by default). For Windows the WinAPI is used directly and for macOS Cocoa is used. So there might be slight differences between platforms anyway so it's recommended that you test your application on these platforms.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: GTK or QT?
« Reply #4 on: September 05, 2021, 12:16:53 pm »
Yes, as previously said, you really only need to choose between GTK2 and Qt5 on Linux, on Windows you will use Win32 and on Mac, its Cocoa.

If you mean which of GTK2, Qt5 is easier to translate to Windows or mac, neither, in my app, I make both a Qt5 and GTK2 version for Linux and just recompile to be Windows or mac.  Very occasionally you might need to put a ifdef in because one widget set or another needs slightly different treatment. But you will have  more (but still not a lot) of ifdefs dealing with other differences between platforms, not related to widget set.

I do occasionally get feedback from my Linux users that they prefer the look of the QT5 set, its trivial to produce either so build something and see what you prefer the look of.

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

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: GTK or QT?
« Reply #5 on: September 05, 2021, 08:52:44 pm »
You shouldn't use gtk or qt on windows but rather windows forms and on MacOs GTK2 is an absolute pain, but i think QT5 works okish, but here cocoa is the way to go.

On Linux the decision is rather simple. GTK2 is officially considered EOL (end of life) by their developers and there will not be any more patches. It is removed from more and more platforms as default system. With respect to QT, while QT6 was also rolled out last year, QT5 is still considered live and, while the official QT team only provides LTS for commercial customers, the KDE Team publishes regular updates and fixes to QT5. Also as the main platform for KDE, it will be shipped with all KDE platforms for the next few years.

So the decision is pretty simple use QT5, especially if you consider developing commercial software, because using EOL libraries is irresponsible and you can be held liable to any bugs or security issues arising from this decision (as, unless otherwise necessary and/or negotiated with the client, you must provide a service according to the state of the art).

bitman

  • Newbie
  • Posts: 5
Re: GTK or QT?
« Reply #6 on: September 07, 2021, 11:00:05 pm »
Thanks everyone for their feedback.

If you mean which of GTK2, Qt5 is easier to translate to Windows or mac, neither,...

Yes, that's what I meant...

I will follow your advice and go with QT, while regularly recompiling for GTK (as sanity check) and more seldomly for Windows (which is the one I've access to); will have to wait until a beta version to try on Mac though ;(

I'm using Qt on Linux, Windows and Mac for years and it suits all my needs.

I wasn't aware that QT could be used on Windows and Mac too... I mean, I know it is crossplatform, but didn't know could also be used via Lazarus in those platforms...

I feel attracted to the idea however, of using QT as engine for all platforms, mainly for its theming capabilities... I know I cannot use mac UI theme on Win nor Linux, but what about the "Fusion" theme (QT own theme)??? could my app use it across all platforms?  Well, I ask this mostly for aesthetic reasons, to achieve an uniform look across platforms; but seeing other people mentioning setting up QT for mac may be hassle, it might not be worth the effort.

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: GTK or QT?
« Reply #7 on: September 07, 2021, 11:14:17 pm »
I feel attracted to the idea however, of using QT as engine for all platforms, mainly for its theming capabilities... I know I cannot use mac UI theme on Win nor Linux, but what about the "Fusion" theme (QT own theme)??? could my app use it across all platforms?  Well, I ask this mostly for aesthetic reasons, to achieve an uniform look across platforms; but seeing other people mentioning setting up QT for mac may be hassle, it might not be worth the effort.

I don't think that a uniform design is a good idea. It is generally said that users preferr if all the applications fit into the system style. This is why Java introduced native style GUIs (before that Java had a unified look on all platforms) or why Android pushed for a more uniform style accross different apps.
I don't really agree with this sentiment, because as software like VSCode or Final Cut have shown, people also like different looking apps, if they are well designed. But personally, I am not a designer, I am terrible at graphical UI design and the default style will always be accepted, so I rather go with that than trying to make a unique look that must be very good to be accepted.

I think the worst thing is if you have a dark-themed system (like I have under Linux) and then there is one app thats not dark themed. Every time I open such an app it is kinda blinding. So personally I think sticking to the default theme a safe option that will always produce a good result
« Last Edit: September 07, 2021, 11:16:01 pm by Warfley »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: GTK or QT?
« Reply #8 on: September 08, 2021, 05:05:45 am »
Thanks everyone for their feedback.
....
I will follow your advice and go with QT, while regularly recompiling for GTK (as sanity check) and more seldomly for Windows (which is the one I've access to); will have to wait until a beta version to try on Mac though ;(

Sorry but I would suggest the other way around, you do need to regularly check under Windows, too easy for a set of issues to build up. And a set is much harder to deal with.  And the switch between Qt and GTK2 on Linux is a non-event. The Mac is an issue ("Its Unix Captain, but not as we know it") but maybe your approach might be to treat that as an extra project. Most things will work fine but there will be issues....

And, yes I agree with the other posters who say that you should use native widget sets on both Windows and Mac. Qt  can be made work there but end users will not appreciate the slightly different look and feel and getting the extra libraries installed is an unnecessary complication with no gain.
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

cappe

  • Full Member
  • ***
  • Posts: 191
Re: GTK or QT?
« Reply #9 on: September 08, 2021, 08:01:38 am »
I'm using Qt on Linux, Windows and Mac for years and it suits all my needs. You must decide on your own what is better on Linux for you, gtk2 is usually installed by default, but gtk2 won't be default installation for so long time since it's pretty old lib now. Gtk3 widgetset isn't finished, on the other side we have Qt and Qt5 WS - stable and continuosly developed and maintaned. My recommendation is definitelly Qt5 if you start fresh project and need stable WS since all distros now pack libQt5Pas C library which is needed by Qt5 WS.

An information, is qt ws by chance like broadway? Yes, I'm interested, is there any example to start with?

Thank you.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: GTK or QT?
« Reply #10 on: September 08, 2021, 08:54:01 am »
I will follow your advice and go with QT, while regularly recompiling for GTK (as sanity check) and more seldomly for Windows (which is the one I've access to); will have to wait until a beta version to try on Mac though ;(

For general tests you could also use WINE instead of Windows. Of course there might be differences between that and Windows itself, but for general tests that might be faster (at least if you need to reboot to test on Windows; if you have a separate computer or a VM that's a different topic).

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: GTK or QT?
« Reply #11 on: September 08, 2021, 10:34:13 am »

I wasn't aware that QT could be used on Windows and Mac too... I mean, I know it is crossplatform, but didn't know could also be used via Lazarus in those platforms...

I feel attracted to the idea however, of using QT as engine for all platforms, mainly for its theming capabilities... I know I cannot use mac UI theme on Win nor Linux, but what about the "Fusion" theme (QT own theme)??? could my app use it across all platforms?  Well, I ask this mostly for aesthetic reasons, to achieve an uniform look across platforms; but seeing other people mentioning setting up QT for mac may be hassle, it might not be worth the effort.

Qt/Qt5 uses native theming on Mac and Win, so app looks exactly same as other OS apps.

CM630

  • Hero Member
  • *****
  • Posts: 1082
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: GTK or QT?
« Reply #12 on: September 08, 2021, 12:03:37 pm »
@Bitman did not say if he intends to distribute the software and under what conditions.
Possibly there are significant licensing issues between GTK and QT (for commercial products)?
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: GTK or QT?
« Reply #13 on: September 08, 2021, 07:19:02 pm »
Qt is LGPL

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: GTK or QT?
« Reply #14 on: September 08, 2021, 11:22:14 pm »
I use native on Win and Mac, gtk2 on Lin.

I found using QT caused additional complications with no benefit. Perhaps the eventual transition to gtk3 will change my mind, but we saw very rapid development of cocoa when carbon went south.

BTW, I develop on Mac, and recompile on Win and Lin using VirtualBox.

EDIT: You can use either on Lin, and still use native on Win and Mac.
« Last Edit: September 08, 2021, 11:32:11 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018