Results 1 to 7 of 7

Thread: How to get reverse rounded corners for QTabWidget using stylesheets?

  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to get reverse rounded corners for QTabWidget using stylesheets?

    I want to get the tab look and feel provided by the latest version of Opera i.e. Opera 10. Here's a screenshot of Opera 10 tabs (it may be same in Opera 9 too):



    As you can see, there is some space between the tabs and the corners of tabs are rounded. In addition the rounded corners at the bottom left and bottom right of the tabs are reverse i.e. they are inclined out.

    I modified the tabdialog example of Qt and came up with this:



    I am using the following style sheet for the above look:

    Qt Code:
    1. QTabWidget::pane { /* The tab widget frame */
    2. border-top: 6px solid qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFE085, stop: 0.8 #CC9900); /* Width of the line below the tab panel */
    3. }
    4.  
    5. QTabWidget::tab-bar {
    6. left: 5px; /* move to the right by 5px */
    7. }
    8.  
    9. /* Tab properties */
    10. QTabBar::tab {
    11. border: 1px solid #000000;
    12. border-top-left-radius: 4px; /* For rounded corners */
    13. border-top-right-radius: 4px;
    14. min-width: 8ex;
    15. padding: 2px; /* Padding inside each tab */
    16. margin-left: 4px; /* Margins among the tabs */
    17. margin-right: 4px;
    18. }
    19.  
    20. /* Properties for selected tab */
    21. QTabBar::tab:selected {
    22. background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #CC9900, stop: 0.8 #FFE085);
    23. border-color: #000000;
    24. border-bottom-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #CC9900, stop: 0.8 #FFE085); /* same as pane color */
    25. }
    26.  
    27. /* Properties for unselected tabs */
    28. QTabBar::tab:!selected {
    29. background: #C2C7CB; /* Gray color for unselected tabs */
    30. border-bottom-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #CC9900, stop: 0.8 #FFE085); /* same as pane color */
    31. margin-top: 4px; /* make non-selected tabs look smaller */
    32. }
    33.  
    34. QTabBar::tab:first:selected {
    35. margin-left: 0; /* the first selected tab has nothing to overlap with on the left */
    36. }
    37.  
    38. QTabBar::tab:last:selected {
    39. margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
    40. }
    To copy to clipboard, switch view to plain text mode 


    As you can see, i was able to put some space between the tabs and also got rounded corners. Now, i don't know how to get the reverse rounded corners at the bottom left and bottom right like the Opera tabs.

    Anybody has a clue?

  2. #2
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    does anybody knows about it? I am pretty sure that there's a way since Opera (written in Qt) is doing it.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    May be they have subclassed the headerview

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    If you want to use style sheets then you could simply use images. For right scaling look in the docs for "QPushButton and images".

  5. #5
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    i was thinking of using images for tabs. Looks like there is no other way of doing this through style sheets.

    Thanks for the help!

  6. #6
    Join Date
    Sep 2009
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    How we can create a style sheet in Visual Studio ?

  7. #7
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get reverse rounded corners for QTabWidget using stylesheets?

    Quote Originally Posted by Peter_APIIT View Post
    How we can create a style sheet in Visual Studio ?
    you can create/write a style sheet in any editor i..e Visual Studio, Notepad etc.
    it's just a text file.

Similar Threads

  1. How to create region with rounded corners
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2009, 09:23
  2. QDialog with rounded corners
    By rossm in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2009, 23:31
  3. Toplevel widget with rounded corners.
    By munna in forum Qt Programming
    Replies: 7
    Last Post: 18th August 2006, 20:46
  4. widget with rounded corners
    By sreedhar in forum Qt Programming
    Replies: 4
    Last Post: 7th June 2006, 12:18

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.