Results 1 to 6 of 6

Thread: How can you make a TabWidget have a flat border (not raised)?

  1. #1
    Join Date
    Apr 2009
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How can you make a TabWidget have a flat border (not raised)?

    The default behavior for a TabWidget is to have its border (around the sides and bottom) as a raised style. I don't like this and it's counter to all the other widgets I've setup, which have no border and are flat. How can I force the tab border to do the same?

    Many thanks.

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can you make a TabWidget have a flat border (not raised)?

    I know that for instance with lables you can use setFrameStyle(QFrame::Plain); But there is no such method for QTabWidget. So i looked through some docs and found that this is usually done with the help of QStyleOptionTabWidgetFrame.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Apr 2009
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How can you make a TabWidget have a flat border (not raised)?

    Quote Originally Posted by lyuts View Post
    I know that for instance with lables you can use setFrameStyle(QFrame::Plain); But there is no such method for QTabWidget. So i looked through some docs and found that this is usually done with the help of QStyleOptionTabWidgetFrame.
    Thanks, that seems like it would work. But, does this mean I have to subclass the tab widget and override the paint method? Is there anyway of creating the QStyleOptionTabWidgetFrame instance and assigning it to the tab widget instance?

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can you make a TabWidget have a flat border (not raised)?

    I haven't tried it myself, but I think you don't have to subclass QTabWidget.
    Instead, take a look at this tab widget's method

    Qt Code:
    1. void initStyleOption ( QStyleOptionTabWidgetFrame * option ) const
    To copy to clipboard, switch view to plain text mode 

    Looks like this is what you need. Create your style option and assign it.
    I'm a rebel in the S.D.G.

  5. #5
    Join Date
    Apr 2009
    Posts
    20
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How can you make a TabWidget have a flat border (not raised)?

    Quote Originally Posted by lyuts View Post
    I haven't tried it myself, but I think you don't have to subclass QTabWidget.
    Instead, take a look at this tab widget's method

    Qt Code:
    1. void initStyleOption ( QStyleOptionTabWidgetFrame * option ) const
    To copy to clipboard, switch view to plain text mode 

    Looks like this is what you need. Create your style option and assign it.
    The docs suggest that just initializes it, almost like initFrom.. But that would be redundant, so I'll try it and see if it works.

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can you make a TabWidget have a flat border (not raised)?

    maybe this can help you.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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.