Lazarus

Installation => Linux => Topic started by: bitman on September 04, 2021, 07:36:48 am

Title: GTK or QT?
Post by: bitman 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!
Title: Re: GTK or QT?
Post by: MarkMLl 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
Title: Re: GTK or QT?
Post by: zeljko 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.
Title: Re: GTK or QT?
Post by: PascalDragon 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.
Title: Re: GTK or QT?
Post by: dbannon 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
Title: Re: GTK or QT?
Post by: Warfley 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).
Title: Re: GTK or QT?
Post by: bitman 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.
Title: Re: GTK or QT?
Post by: Warfley 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
Title: Re: GTK or QT?
Post by: dbannon 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
Title: Re: GTK or QT?
Post by: cappe 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.
Title: Re: GTK or QT?
Post by: PascalDragon 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).
Title: Re: GTK or QT?
Post by: zeljko 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.
Title: Re: GTK or QT?
Post by: CM630 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)?
Title: Re: GTK or QT?
Post by: zeljko on September 08, 2021, 07:19:02 pm
Qt is LGPL
Title: Re: GTK or QT?
Post by: VTwin 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.
Title: Re: GTK or QT?
Post by: Leledumbo on September 17, 2021, 01:55:42 pm
When making cross platform apps, I usually prefer each platform's native interface, if they have one. If they have two, well, provide two :P
As long as you adhere to LCL Autosize / Layout (https://wiki.lazarus.freepascal.org/Autosize_/_Layout), meaning you're not doing any absolute sizing / layouting, any backend should show similarly well laid out controls.
Title: Re: GTK or QT?
Post by: bitman on September 18, 2021, 10:57:58 pm
A quick update...

I ultimately had to go with GTK, because of this:

https://forum.lazarus.freepascal.org/index.php/topic,48275.15.html

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/36483

The IDE code editor is unusable in certain versions of QT. Fonts are a real mess, making impossible to do any work; nothing else mattered. Supposedly there is some patch, but didn't know exactly how to apply it, while the problem is absent in GTK... so, there's that  :sighs:
Title: Re: GTK or QT?
Post by: Jurassic Pork on September 19, 2021, 08:23:36 am
hello,
GTK2 is now EOL and  newer  GTK linux distribution versions use GTK3 by default.
On Ubuntu 20.04 LTS i have a project for image processing. When i use gtk2 as LCL widgetset i have some error messages at run time :
Quote
Gtk-Message: 13:32:49.621: Failed to load module "canberra-gtk-module"
GLib-GObject-WARNING **: 13:32:51.031: ../../../gobject/gsignal.c:1282: no emission of signal "key-release-event" to stop for instance '0x2628350'
Read this topic: GTK2 is now EOL :( (https://forum.lazarus.freepascal.org/index.php/topic,52848.msg390372.html#msg390372)   

Friendly, J.P
Title: Re: GTK or QT?
Post by: dbannon on September 21, 2021, 12:14:57 pm
I ultimately had to go with GTK, because of this:
(a font problem in the IDE)

I suspect that you believe you have to use the same widget set in the ide that your application uses ?   That is not the case, absolutely no reason why you cannot have a GTK2 based IDE and produce (and test, debug, everything) a QT5 app.  Mixing does not make any part of the process any harder once you have selected QT5 Widgetset in ProjectOptions.  Normally, for a cross platform app, you will define in your project a mode for GTK2, QT5, Windows, MacOS, perhaps Raspberry Pi and maybe GTK3 (?).

Indeed, that same GTK2 IDE (as long as you have setup FPC cross compilers) will also make Windows and Raspberry Pi binaries. But no special cross compile setup needed to make QT5, it just works.

Davo
 
Title: Re: GTK or QT?
Post by: VTwin on September 21, 2021, 02:41:42 pm
hello,
GTK2 is now EOL and  newer  GTK linux distribution versions use GTK3 by default.
On Ubuntu 20.04 LTS i have a project for image processing. When i use gtk2 as LCL widgetset i have some error messages at run time :
Quote
Gtk-Message: 13:32:49.621: Failed to load module "canberra-gtk-module"
GLib-GObject-WARNING **: 13:32:51.031: ../../../gobject/gsignal.c:1282: no emission of signal "key-release-event" to stop for instance '0x2628350'
Read this topic: GTK2 is now EOL :( (https://forum.lazarus.freepascal.org/index.php/topic,52848.msg390372.html#msg390372)   

Friendly, J.P

gtk3 is not even on the roadmap yet:

https://wiki.freepascal.org/Roadmap

It would be great if we could see what progress has been made, and it might inspire some bounties or donations.

Cheers
Title: Re: GTK or QT?
Post by: Zvoni on September 21, 2021, 03:45:54 pm
gtk3 is not even on the roadmap yet:

https://wiki.freepascal.org/Roadmap

It would be great if we could see what progress has been made, and it might inspire some bounties or donations.

Cheers
https://wiki.freepascal.org/GTK3_Interface
Quote
Current bindings (12.01.2021) are 3.8.6 and there's a plan to move it to 3.22 
Title: Re: GTK or QT?
Post by: af0815 on September 21, 2021, 04:58:45 pm
Is there any information about the state of gtk3 ?


Edit: I should ask for 'actual' state of gtk3.
Title: Re: GTK or QT?
Post by: prof7bit on October 02, 2021, 04:53:17 pm
Fortunately with Lazarus you can defer this decision indefinitely and just use whatever seems best at the moment ;-)

I personally have used  GTK2 on Linux for a long time, until I recently upgraded some of my *buntu boxes to the 21.04 release and found that they are now very aggressively phasing out GTK2 support, removing theme support for GTK2, etc.

Fortunately the Qt5 widgetset has become very good in the meantime, I have upgraded from Lazarus 2.0 to the 2.2 branch earlier this year and at the same time I began gradually switching all my old projects over to Qt5. This is causing ZERO problems so far, exactly as one would expect with such an excellent versatile Toolkit that Lazarus is.
Title: Re: GTK or QT?
Post by: funlw65 on November 07, 2021, 10:11:04 am
Qt5 license could change anytime?

Guys, I think it will come a day when Lazarus will have to decide for it's own pascal native widgetset, with a certain look and two main themes (dark and light). Going all the way with Qt5 won't be secure.  But yes, today Qt5 is the recommended choice.
Title: Re: GTK or QT?
Post by: JuhaManninen on November 07, 2021, 10:55:11 am
Qt5 license could change anytime?
Why would it? This same fear mongering has continued since the last millenium.

Quote
Guys, I think it will come a day when Lazarus will have to decide for it's own pascal native widgetset, with a certain look and two main themes (dark and light). Going all the way with Qt5 won't be secure.  But yes, today Qt5 is the recommended choice.
There already is CustomDrawn widgetset and also bindings for the fpGUI library.
Both are alpha state. Felipe has other priorities and does not maintain CustomDrawn any more.
Contributions are welcome!
What means "Going all the way with Qt5"? The idea is to have many widgetsets, not only one.

Information about the 'actual' state of LCL-GTK3 bindings can be obtained by testing it. Patches / merge requests to fix bugs are welcome, too.
Title: Re: GTK or QT?
Post by: dbannon on November 07, 2021, 11:09:28 am
Going all the way with Qt5 won't be secure.

But there is just about no way you can "Go all the way with Qt5" even if you wanted to.  Select GTK2 (or some time in the future GTK3, maybe even GTK4) with a couple of clicks. Its an each way bet on a three horse race !

Davo
Title: Re: GTK or QT?
Post by: avra on November 09, 2021, 09:41:15 am
Qt5 license could change anytime?

QT licensing has been discussed:
https://forum.lazarus.freepascal.org/index.php/topic,55440.msg415530.html#msg415530
https://forum.lazarus.freepascal.org/index.php/topic,49100.0.html
TinyPortal © 2005-2018