Recent

Author Topic: QT5 Styles or Themes ?  (Read 3387 times)

mosquito

  • Jr. Member
  • **
  • Posts: 71
QT5 Styles or Themes ?
« on: July 16, 2021, 09:48:31 am »
In an application built with QT5:

- Can the theme style be changed?
- Can you change the color of the scrollbar?
- If it was not possible from lazarus, would you have to recompile Qt5Widgets.dll?

I mean the style of a standaolone application (crossplatform way), not to change it through a theme manager from the system, such as KDE preferences on Linux, etc.

dbannon

  • Hero Member
  • *****
  • Posts: 1674
    • tomboy-ng, a rewrite of the classic Tomboy
Re: QT5 Styles or Themes ?
« Reply #1 on: July 16, 2021, 10:46:59 am »
Mosquito, given that you mention a DLL file, I guess you are using Windows ?

There is a discussion, totally in a Linux sense, on this topic - https://forum.lazarus.freepascal.org/index.php/topic,55348.msg412093 going on right now.  We are finding that in some linux distribution/desktop combinations Qt5 apps follow the DE theme and some do not.

My experience is that under windows, no lazarus app follows the user selected theme.

In linux, there is a tool called qt5ct that sets up a colour scheme for QT5 apps to follow. It works reliably but is one more step where users just expect these things to happen. I get the impression Windows users don't quite have that expectation ...

Anyway, might be worthwhile trying to find if there is a Windows tool that does the same as qt5ct ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

mosquito

  • Jr. Member
  • **
  • Posts: 71
Re: QT5 Styles or Themes ?
« Reply #2 on: July 16, 2021, 11:01:21 am »
Thanks Davo,
I actually work with Debian Sid Kde, where I am very happy with lazarus QT applications. (GTK also perfect). Although the application drinks from the system themes, it is possible to change colors from lazarus to controls, that is, perfect customization to create a Dark Theme independent of the distribution.

The problem is the tests I have done for Windows, where the default theme is light with blue touches. (very similar to the native win widgetset). Unable to create a "Dark Theme".

For example in GTK2 for Windows, you can attach a complete theme to a folder inside the executable and thus distribute the application with a custom theme. In QT I do not see this possibility, except that from QT Creator or similar (which I am completely unaware of) .dll's can be generated with custom themes.

Even so, I think that the default theme for win that lazarus compiles for QT5, is much more stylized, since the one with Windows by default has bright and disproportionately wide scrollbars that break any possibility of an application with its own style.
« Last Edit: July 16, 2021, 11:13:48 am by mosquito »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3996
  • I like bugs.
Re: QT5 Styles or Themes ?
« Reply #3 on: July 16, 2021, 12:13:12 pm »
- Can the theme style be changed?
Yes, you can pass -style parameter to your application. For example: ./myapp -style windows
Zeljko has told it when asking to test issues. For example here:
 https://bugs.freepascal.org/view.php?id=37576
I don't think it is documented anywhere. It should be documented here at least:
 https://wiki.lazarus.freepascal.org/Qt5_Interface
Unfortunately I don't know all the supported themes. Zeljko, are you reading this?
I also don't have time to document it now. It must go to a proper place in the wiki page. If somebody does it, good. Otherwise I can do it next week.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

zeljko

  • Hero Member
  • *****
  • Posts: 1191
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT5 Styles or Themes ?
« Reply #4 on: July 16, 2021, 12:15:27 pm »
You can see available themes if you start app with -style BLABLA, changing theme variations, controls etc is possible by using Qt stylesheets, so read Qt docs.

dbannon

  • Hero Member
  • *****
  • Posts: 1674
    • tomboy-ng, a rewrite of the classic Tomboy
Re: QT5 Styles or Themes ?
« Reply #5 on: July 16, 2021, 01:15:31 pm »
-style does not set the colours, more the style, border shape etc.

Available styles : cleanlooks, gtk2, cde, motif, plastique, qt5ct-style, Windows, Fusion

Certainly, a similar option to set actual colours, particularly "Dark" would be a good thing. But it appears that the list of colours is in /usr/share/qt5ct/colors and therefore a qt5ct thing.

Davo

Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

dbannon

  • Hero Member
  • *****
  • Posts: 1674
    • tomboy-ng, a rewrite of the classic Tomboy
Re: QT5 Styles or Themes ?
« Reply #6 on: July 16, 2021, 01:34:15 pm »
In terms of feedback on the -style option, it would be nice if it followed the more standard style we use here -

--style=gtk2
or, less preferable because it might clash with an existing one -
-s gtk2

As it is, my application for example will reject it a error on the command line.

EDIT:  woops, I note that --style=motif   works too !   Sorry.

Davo
« Last Edit: July 16, 2021, 01:42:25 pm by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018