Bug 347971 - Qscrollbar fails to behave correctly when the main widget is transparent
Summary: Qscrollbar fails to behave correctly when the main widget is transparent
Status: REOPENED
Alias: None
Product: Breeze
Classification: Plasma
Component: QStyle (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Hugo Pereira Da Costa
URL: https://github.com/qbittorrent/qBitto...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-19 21:57 UTC by Nick
Modified: 2017-06-01 11:42 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Qbittorrent Scrollbar (246.86 KB, image/png)
2015-05-19 21:57 UTC, Nick
Details
Screenshot of the wrong styled scrollbar (17.07 KB, image/png)
2017-05-31 14:18 UTC, Tobias Leupold
Details
Demo database (20.00 KB, application/x-sqlite3)
2017-05-31 17:22 UTC, Tobias Leupold
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick 2015-05-19 21:57:09 UTC
Scrollbars sometimes appear black when the widget is transparent. This happens with Qbittorrent compiled against Qt5 and probably other applications as well. See https://github.com/qbittorrent/qBittorrent/issues/2930 

Qt 5.4.1

Reproducible: Always
Comment 1 Nick 2015-05-19 21:57:46 UTC
Created attachment 92721 [details]
Qbittorrent Scrollbar
Comment 2 Hugo Pereira Da Costa 2015-05-21 07:58:52 UTC
Hi
Can reproduce
working on it.
Comment 3 Hugo Pereira Da Costa 2015-05-21 13:25:42 UTC
(In reply to Nick from comment #0)
> Scrollbars sometimes appear black when the widget is transparent. This
> happens with Qbittorrent compiled against Qt5 and probably other
> applications as well.

do you have any example of "and probably other applications as well"  ? 

Investigating locally, I find that the issues is triggered by 
    scroll->setStyleSheet("QFrame { background: transparent; }");
(line 770 of transferlistfilterswidget.cpp)

Not sure this is a widely used feature :)

In any case, I'll try to find a workaround.
Comment 4 Nick 2015-05-21 13:33:08 UTC
Sorry, I don't. I didn't realize it was an uncommon feature. I should probably avoid making such assumptions in bug reports :) Thanks for looking in to it!
Comment 5 Hugo Pereira Da Costa 2015-05-21 14:11:47 UTC
Git commit 02ceed6ef677618a171aeb8dce1e240a74c0e161 by Hugo Pereira Da Costa.
Committed on 21/05/2015 at 14:11.
Pushed by hpereiradacosta into branch 'Plasma/5.3'.

- Cleanup tests in scrollarea event filter
- do not render background behind scrollbars when parent scrollarea has a stylesheet set, because the viewport palette is broken
(all black)

M  +6    -5    kstyle/breezestyle.cpp

http://commits.kde.org/breeze/02ceed6ef677618a171aeb8dce1e240a74c0e161
Comment 6 Hugo Pereira Da Costa 2015-05-21 14:11:48 UTC
Git commit 46ca7603843b0215d13560f4b68b6139b4d61c6d by Hugo Pereira Da Costa.
Committed on 21/05/2015 at 14:09.
Pushed by hpereiradacosta into branch 'master'.

- Cleanup tests in scrollarea event filter
- do not render background behind scrollbars when parent scrollarea has a stylesheet set, because the viewport palette is broken
(all black)

M  +6    -5    kstyle/breezestyle.cpp

http://commits.kde.org/breeze/46ca7603843b0215d13560f4b68b6139b4d61c6d
Comment 7 Nick 2015-05-22 23:13:38 UTC
Looks like that fixed it. Thanks!
Comment 8 Tobias Leupold 2017-05-31 14:18:08 UTC
This is rather old, but I ran into exactly the same issue with a Qt program and Breeze 5.8.6 (cf. the attached screenshot).

No style has been added/changed using the QScrollArea that displays the black scrollbar, the only thing done is setFrameShape(QFrame::NoFrame). The sources can be found at http://git.l3u.de/?p=muckturnier.git .

This is definitely Breeze dependant: When I use the Oxygen style, a normal scrollbar appears. Either, the original issue has not been fixed for all cases, or this is a regression.
Comment 9 Tobias Leupold 2017-05-31 14:18:48 UTC
Created attachment 105802 [details]
Screenshot of the wrong styled scrollbar
Comment 10 Hugo Pereira Da Costa 2017-05-31 15:16:44 UTC
(In reply to Tobias Leupold from comment #8)
> This is rather old, but I ran into exactly the same issue with a Qt program
> and Breeze 5.8.6 (cf. the attached screenshot).
> 
> No style has been added/changed using the QScrollArea that displays the
> black scrollbar, the only thing done is setFrameShape(QFrame::NoFrame). The
> sources can be found at http://git.l3u.de/?p=muckturnier.git .
> 
> This is definitely Breeze dependant: When I use the Oxygen style, a normal
> scrollbar appears. Either, the original issue has not been fixed for all
> cases, or this is a regression.

Thanks for the report,
This is not a regression, but rather an improper fix, due to the fact that the original report was slightly different (the broken scrollbar was the result of a stylesheet being set, while in your case this is the result of a "noFrame" being set). Anyway, I'll investigate.
Comment 11 Hugo Pereira Da Costa 2017-05-31 15:58:59 UTC
Tried to compile and run the provided code but cannot reproduce the issue because 
the main window stays disabled (I miss some background app it seems).

Is there a chance you make a "simple" program that reproduces the issues in a straigtforward way ? 

I have here quite some code with NoFrame ScrollArea, that does not reproduce the issue though, so there must be more to it.
(see: http://i.imgur.com/MJtpmas.png)

Or does it happen only with horizontal bars ?
Comment 12 Tobias Leupold 2017-05-31 17:22:11 UTC
Created attachment 105804 [details]
Demo database

You can use this database with my program to see the error. Just start it with the file as a command line argument (sorry, I didn't think it through when just posting the sources ;-), and you should see the relevant part.

The respective code lives in src/ScorePage.cpp.

If this doesn't work for you, I can try to strip it down to a minimal example, but of course, it would be less work if you could see it using the demo db.
Comment 13 Hugo Pereira Da Costa 2017-06-01 09:43:40 UTC
ok. With the provided demo db, I can reproduce the problem. Thanks ! 

Investigating.
Comment 14 Hugo Pereira Da Costa 2017-06-01 10:04:37 UTC
Investigating,     
"app.setStyleSheet(STYLE);"
is what causes the issue, similar, in fact, to the original report. (but the stylesheet was applied to the scrollarea, not to the application).

The real issue is upstream: why, as soon as a style sheet is set, the viewport's pallette become broken 
(and it is broken here. It returns #000000 for its background color)

Now, I can also check for application styleSheet (on top of the widget's), but the most most complete test would be to check on app, or any parent of the view port, though.

or of course to fix the upstream issue.
I'll investigate some more ...
Comment 15 Hugo Pereira Da Costa 2017-06-01 10:11:07 UTC
ok. In fact, the issue is "QScrollArea { background-color: transparent;" in the stylesheet you set. 
This is the color I retrieve, which then breaks the code. 
I'll try protect against this.
Comment 16 Tobias Leupold 2017-06-01 11:42:16 UTC
Thanks for tracking this down! I actually forgot that there's an application-wide style sheet set in main.cpp and thus claimed that no style was applied to the scrollarea (I think I set this back then because the background color was wrong on my Windows build of the program).

Best thing would of course be to fix the issue upstream, if it's a upstream bug.