PDA

View Full Version : Hiding the QTabBar of a QTabWidget



elcuco
23rd March 2007, 19:30
I have this tab widget, which I want to hide it's tabbar. How can I do this? I wanted to use QTabWidget::tabBar()->hide() but tabBar() is not a public interface.

The only idea I have is to constcut my own QTabBar, pass it to the QTabWidget and then have full control of that widget outside QTabWidget's interface. I fell this is too ugly to implement, and I am looking for a sane and better implementation.

wysota
23rd March 2007, 21:51
Why would you want to do that? Why not simply take a QStackedWidget instead? It's exactly a QTabWidget without a QTabBar...

elcuco
23rd March 2007, 21:56
Yes, I tought of that as well (and I implemented this once using a QWorkspace, so I should know how to do this properly). But still, it seems ugly... I am hoping to find some smarter way of doing this.

wysota
23rd March 2007, 22:09
I don't think it's ugly, but if you insist, then use qFindChild (or simmilar) to find the tabbar within the tab widget so that you can access it directly.

giverson
26th March 2007, 14:59
Yes, I tought of that as well (and I implemented this once using a QWorkspace, so I should know how to do this properly). But still, it seems ugly... I am hoping to find some smarter way of doing this.

For some implementations, it's easier using the setHidden(boolean) member on the widgets.

In most cases, that's pretty ugly, though.

For example, if you wanted to toggle between 2 widgets, you could use...

y.setHidden(true);

Toggle()
{
x.setHidden(!x.isHidden());
y.setHidden(!y.isHidden());
}