PDA

View Full Version : styling Tabbar of QDockWidgets



FelixB
19th July 2011, 11:03
Hi,

now I want to customize the TabBars when QDockWidgets are tabbed. I can change the tabs, but I can't access the tab-bar and the pane. See the desired result in attached image. I want to add a background color gradient and a border around the pane and I want to move the tabs by 3 px to the right.


/* Tab */
QTabWidget::pane /* this does not work with tabbed QDockWidgets! */
{
margin-top:-26Px;
background-color:red;
border:1px solid #959595;
padding-top:2px;
border-radius: 2px;
}

QTabWidget::tab-bar /* this does not work with tabbed QDockWidgets! */
{
border:none;
left:3px;
}

is there any special way to access tabbars/pane of tabbed qdockwidgets?

thanks!
Felix

Aleksandar
19th July 2011, 17:37
Did You try this:
QList<QDockWidget *> QMainWindow::tabifiedDockWidgets ( QDockWidget * dockwidget ) const


Access desired widget from the list and get it's parent! It's parent can be either QMainWindow or QTabWidget.
QObject * QObject::parent () const


If You have pointer to desired QTabWidget You can just get it's parrent without geting the list of pointers.

FelixB
20th July 2011, 08:48
thank you for your reply. I did not try your method because findChildren<QTabBar*>() does the same. Of course I can access the QTabBars that way. But I want to set a StyleSheet which does not work for elements "QTabWidget::pane" and "QTabWidget::tab-bar".

Now I found the reason and a solution: tabbing QDockWidgets does not create a QTabWidget. But, I can change QTabBar directly :)


QTabBar
{
height:26px;
background-image:url(:/assets/tabBackground);
border:1px solid #959595;
padding-top:3px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
margin-top:5px;
}

sjaideep93
21st July 2011, 09:25
dont know whether this will help you or not...

http://labs.qt.nokia.com/2007/06/22/styling-the-tab-widget/