Results 1 to 6 of 6

Thread: Customizing QToolBox:tab

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Customizing QToolBox:tab

    Hi all!

    I'd like to customize QToolBox. By default, the tab header text is aligned to left. It is necessary to align it to center horizontally. I can't find a way to do it. Is it possible?

  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: Customizing QToolBox:tab

    I guess using style sheets is the easiest way.
    http://doc.trolltech.com/4.5/stylesheet.html
    ==========================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
    Feb 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Customizing QToolBox:tab

    Quote Originally Posted by high_flyer View Post
    I guess using style sheets is the easiest way.
    http://doc.trolltech.com/4.5/stylesheet.html
    Thanks.
    I know about style sheets. But it seems that there is no way to set QToolBox:tab text align to center. Please, try to do it and if you find solution, share it with me.

  4. #4
    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: Customizing QToolBox:tab

    I would try something like:
    Qt Code:
    1. QToolBox::tab {
    2. text-align: center;
    3. }
    To copy to clipboard, switch view to plain text mode 
    ==========================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.

  5. #5
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Customizing QToolBox:tab

    Quote Originally Posted by high_flyer View Post
    I would try something like:
    Qt Code:
    1. QToolBox::tab {
    2. text-align: center;
    3. }
    To copy to clipboard, switch view to plain text mode 
    I tried it before. It doesn't work.
    If it was so simple, I wouldn't submit this question.
    Are there any real expert?

  6. #6
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    1
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Customizing QToolBox:tab

    Quote Originally Posted by ialnik View Post
    I tried it before. It doesn't work.
    If it was so simple, I wouldn't submit this question.
    Are there any real expert?
    text-align only works with QPushButton and QProgressBar anyways, so that's not going to work. Since ::tab is a sub-control, have you looked at using the subcontrol-origin and subcontrol-position properties? This may just align the tab within the tool box though. The brute force way, though, may have to be manually padding the text and looking at the results unless someone has specifically encountered your problem before.

Similar Threads

  1. Customizing QFileDialog
    By ScabrusMantra in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2011, 12:03
  2. customizing QScrollbar
    By MarkoSan in forum Qt Programming
    Replies: 7
    Last Post: 15th October 2009, 18:51
  3. Customizing Sorting
    By delalaym in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2009, 00:22
  4. Customizing QTabBar::scroller
    By chaoticbob in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2008, 10:16
  5. Customizing QScrollBar
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 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.