Results 1 to 4 of 4

Thread: Cannot add background to QTabWidget's Tab

  1. #1
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Cannot add background to QTabWidget's Tab

    Hallo,
    I have a QTabWdget with 3 Tabs. First 2 of them are widgets derived from QwtPlot. In their constructor I add style sheet with black background. And everything works well, tabs are black around the plot, when i resize window new space is also black.

    But with the third tab this doesn't work. The third widget is different. It is created in QtDesigner. There is QWidget which contain QGridLayout and another QWidget with fixed size in the center of the QGridLayout (I want it to be always in the center of the screen). The center widget contains some QLabels and i want the entire Window to be black. So tried those things:

    - tried to add style to 3 Tab by settin style sheet to last tab of QTabWidget object - doesn't work - black background is only behind area of center widget but not behind the top level QWidget and entire tab
    - Set style to top level QWidget (which contains QGridLayout) - the same as above
    - Tried to add some QLabel in the constructor of object which use form created in QtDesigner. Also set background style in that object's constructor.
    It looks like that: -> in attachments
    Would you help me?
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Cannot add background to QTabWidget's Tab

    Is it really so difficult thing that nobody knows solution?

  3. #3
    Join Date
    May 2011
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot add background to QTabWidget's Tab

    Hard to say - stylesheets should do that. It'd be helpful to see your .ui file.

  4. #4
    Join Date
    Sep 2011
    Posts
    86
    Thanks
    4
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Cannot add background to QTabWidget's Tab

    Hey jazuju
    I've just found the solution. First i looked at QwtPlot's source code and saw that plots are derived from QFrame.
    When i inherited my QtDesigner's ui class from QFrame it works.

Similar Threads

  1. Replies: 6
    Last Post: 21st August 2013, 12:53
  2. Replies: 0
    Last Post: 5th April 2011, 13:36
  3. Replies: 1
    Last Post: 25th June 2010, 18:31
  4. QTabWidget transparent background problem
    By destroyar0 in forum Qt Programming
    Replies: 10
    Last Post: 25th June 2009, 12:19
  5. Changing the background of QTabWidget
    By ike in forum Qt Tools
    Replies: 2
    Last Post: 7th November 2008, 13:43

Tags for this Thread

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.