PDA

View Full Version : Cannot add background to QTabWidget's Tab



code_err
29th September 2012, 19:18
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?

code_err
30th September 2012, 19:56
Is it really so difficult thing that nobody knows solution?

jazuju
1st October 2012, 15:12
Hard to say - stylesheets should do that. It'd be helpful to see your .ui file.

code_err
1st October 2012, 16:45
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.