Recent

Author Topic: Qt5 Panel Transparent ?  (Read 412 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1167
    • tomboy-ng, a rewrite of the classic Tomboy
Qt5 Panel Transparent ?
« on: September 22, 2020, 10:19:06 am »
I just noticed something strange, a difference between the way GTK2 and Qt5 panels work.

I have a form that serves two purposes, only difference is some controls at the top. So, I have two panels, one partially overlaying the other. The upper panel may, or may not be visible.

But I find I can see labels on the lower panel even when the upper panel is visible.

Attached image show the text of the two panels mixed together.  This does not happen with GTK2 (nor, I think, Windows/MacOS).  Is this intentional ?

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

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: Qt5 Panel Transparent ?
« Reply #1 on: September 22, 2020, 11:42:42 am »
Hi!

I don't use Qt but I have a suggestion:

It would not be the first time that those weird system colors make trouble.
I mean clHighlight, clGreyText, ...

Replace it with a real RGB Color like $FF00FF.

And let's see what happens.

Winni

wp

  • Hero Member
  • *****
  • Posts: 7642
Re: Qt5 Panel Transparent ?
« Reply #2 on: September 22, 2020, 11:52:05 am »
But I find I can see labels on the lower panel even when the upper panel is visible.
I think it is better to physically hide the lower labels by setting their Visible to false than relying on a widgetset-dependent property like transparency. Or use a multi-page control like TNoteBook if you want to hide/show controls depending on context.

It would not be the first time that those weird system colors make trouble.
I mean clHighlight, clGreyText, ...

Replace it with a real RGB Color like $FF00FF.

And let's see what happens.
What will happen is that when you set a text color to clBlack the next guy will activate dark mode and will wonder why he cannot read the black text on the black background.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: Qt5 Panel Transparent ?
« Reply #3 on: September 22, 2020, 01:38:49 pm »

What will happen is that when you set a text color to clBlack the next guy will activate dark mode and will wonder why he cannot read the black text on the black background.

We are talking about the Panel.color

Again: You missed the topic.

Winni

dbannon

  • Hero Member
  • *****
  • Posts: 1167
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 Panel Transparent ?
« Reply #4 on: September 23, 2020, 02:01:04 am »
I think it is better to physically hide the lower labels by setting their Visible to false than relying on a widgetset-dependent property like transparency. Or use a multi-page control like TNoteBook if you want to hide/show controls depending on context.
Yes, thanks folks, rather than using Visible, I have now moved the common parts to a third panel and set one or the other of the remaining panels to zero width. TNotebook seemed like overkill.
I do not want to alter default colours, on linux various desktops allow users to set their own and they don't like it being ignored. And, as WP points out, dark themes, sigh...  I have to override the colours in Windows and thats messy enough.
[/quote]

But I guess my real question is should this be considered a Qt5 bug and reported or the workounds suggested by WP and Winni be added to wiki ?

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

winni

  • Hero Member
  • *****
  • Posts: 1908
Re: Qt5 Panel Transparent ?
« Reply #5 on: September 23, 2020, 02:50:17 am »
Hi!

The background:

Everybody uses the 4 color bytes as R/G/B/Alpha

30 Years ago Microsoft did not know anything about the Alpha Channel.
In the type definition the 4th byte is named "unused". And as you see with the TBitmap and the lousy workaround with the TransparentColor.

They came to the idea in the "unused " byte to save the info for the system colors.

But everybody uses byte 4 as alpha channel.

So the bug for QT goes this way:
Some logic assumes that byte 4 is the alpha channel.
But there is some value for the system colors.
This value is the reason for the transpareny.

So this is a bug.
They forgot to convert the system color to a RGB color before painting.

The magic solution is the procedure

Color := ColorToRGB(SystemColor);   

Hope it's only in the Panel ....

Winni
« Last Edit: September 23, 2020, 02:53:21 am by winni »

zeljko

  • Hero Member
  • *****
  • Posts: 1149
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt5 Panel Transparent ?
« Reply #6 on: September 23, 2020, 10:47:19 am »
This is not bug. Qt panels are transparent per default (controlled by current Qt style).
If you want non transparent panel then MyPanel.ControlStyle := MyPanel.ControlStyle + [csOpaque] should work (if not then it's bug).

dbannon

  • Hero Member
  • *****
  • Posts: 1167
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt5 Panel Transparent ?
« Reply #7 on: September 23, 2020, 01:46:16 pm »
Right !  Thats a definitive answer !

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

 

TinyPortal © 2005-2018