Results 1 to 6 of 6

Thread: Qt Widgets seen half transparent when using stylesheets

  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Qt Widgets seen half transparent when using stylesheets

    Hi,

    I'm in a weird situation, which I'm not sure is a bug or not. Basically, I have a QMainWindow with a QTabWidget. The style sheet for the QMainWindow is:

    Qt Code:
    1. color: rgb(227, 227, 227);
    2. font: 75 10pt "Lucida Sans";
    3. }
    4.  
    5. QMainWindow, QWidget#mywidgetWidget, QTabWidget, QWidget#tabGeneral, QWidget#tabPlugins {
    6. background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(43, 43, 43, 141), stop:0.497175 rgba(0, 0, 0, 147), stop:0.497326 rgba(0, 0, 0, 147), stop:1 rgba(90, 90, 90, 147));
    7. }
    To copy to clipboard, switch view to plain text mode 

    While the style sheet for the QTabWidget is basically the example from the docs:

    Qt Code:
    1. QTabWidget::pane { /* The tab widget frame */
    2. border-top: 2px solid #C2C7CB;
    3. }
    4.  
    5. QTabWidget::tab-bar {
    6. left: 5px; /* move to the right by 5px */
    7. }
    8.  
    9. /* Style the tab using the tab sub-control. Note that
    10. it reads QTabBar _not_ QTabWidget */
    11. QTabBar::tab {
    12. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    13. stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
    14. stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
    15. border: 2px solid #C4C4C3;
    16. border-bottom-color: #C2C7CB; /* same as the pane color */
    17. border-top-left-radius: 4px;
    18. border-top-right-radius: 4px;
    19. min-width: 8ex;
    20. padding: 2px;
    21. }
    22.  
    23. QTabBar::tab:selected, QTabBar::tab:hover {
    24. background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    25. stop: 0 #fafafa, stop: 0.4 #f4f4f4,
    26. stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
    27. }
    28.  
    29. QTabBar::tab:selected {
    30. border-color: #9B9B9B;
    31. border-bottom-color: #C2C7CB; /* same as pane color */
    32. }
    33.  
    34. QTabBar::tab:!selected {
    35. margin-top: 2px; /* make non-selected tabs look smaller */
    36. }
    37.  
    38. /* make use of negative margins for overlapping tabs */
    39. QTabBar::tab:selected {
    40. /* expand/overlap to the left and right by 4px */
    41. margin-left: -4px;
    42. margin-right: -4px;
    43. }
    44.  
    45. QTabBar::tab:first:selected {
    46. margin-left: 0; /* the first selected tab has nothing to overlap with on the left */
    47. }
    48.  
    49. QTabBar::tab:last:selected {
    50. margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
    51. }
    52.  
    53. QTabBar::tab:only-one {
    54. margin: 0; /* if there is only one tab, we don't want overlapping margins */
    55. }
    To copy to clipboard, switch view to plain text mode 


    Basically, when I switch tabs, you can see a "ghost" of the old widgets very faintly. These ghosts disappear. This issue doesn't happen when I remove the stylesheet from the QTabWidget. Any feedback is appreciated.


    Before.pngmywidget.uiAfter.png
    [WIKI]Building Qt on Windows CE[/WIKI]

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Widgets seen half transparent when using stylesheets

    Interesting.
    In your style sheet you are using the alpha channel in your gradient, which you don't really need.
    What happens if you remove the alpha channel, or sett it to 255?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Widgets seen half transparent when using stylesheets

    When you remove the stylesheet, it isn't white on black?
    I wouldn't rule out the hardware. Looks like a little pixel burning, especially cause it is going away.
    Have you got a LED screen to test it on? does is happen on all monitors? You might want to check it out, to rule out that possibility.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt Widgets seen half transparent when using stylesheets

    As high_flyer mentioned above, I would blame the alpha channel from this stylesheet:
    Qt Code:
    1. QMainWindow, QWidget#mywidgetWidget, QTabWidget, QWidget#tabGeneral, QWidget#tabPlugins {
    2. background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 rgba(43, 43, 43, 141), stop:0.497175 rgba(0, 0, 0, 147), stop:0.497326 rgba(0, 0, 0, 147), stop:1 rgba(90, 90, 90, 147));
    3. }
    To copy to clipboard, switch view to plain text mode 
    Try replacing rgba with rgb ( and remove the fourth value in brackets as well ).

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt Widgets seen half transparent when using stylesheets

    Pixel burning wouldn't show up in a screen shot.

  6. #6
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt Widgets seen half transparent when using stylesheets

    Pixel burning wouldn't show up in a screen shot.
    Very true.

Similar Threads

  1. Transparent Widgets overVideo
    By HeReSY in forum Qt Programming
    Replies: 2
    Last Post: 2nd July 2010, 23:36
  2. Replies: 2
    Last Post: 31st May 2010, 11:57
  3. Replies: 1
    Last Post: 18th September 2009, 10:32
  4. Transparent widgets on top of QGLWidget
    By tseval in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2007, 21:03
  5. Transparent widgets
    By incapacitant in forum Newbie
    Replies: 10
    Last Post: 21st March 2006, 18:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.