[Qt-interest] way to get QTabWidget to not show tab when only one tab is there?
Stephen Jackson
spjackson42 at gmail.com
Tue Sep 15 00:17:53 CEST 2009
On Mon, Sep 14, 2009 at 10:55 PM, Evan Teran wrote:
> I was just wondering if there is a simple way to get QTabWidget to not show
> any tabs if there is only a single tab.
>
> >From the documentation, I am guessing the answer is no :-P.
>
> My only work around I can think of would be to use a QTabBar and tie it's
> functionality to a QStackedWidget to emulate the functionality of a
> QTabWidget. This way I would have the freedom to set the QTabBar's
> visibility to false when the QStackedWidget has a count of 1. Thoughts?
>
I have done this very recently in PyQt where it is as simple as:
# If there is only one tab then we don't want to show a tab bar.
if len(pages) == 1:
self.tabWidget.tabBar().hide()
It looks like you'd need to derive from QTabWidget in C++ since
tabBar() is a protected function.
--
HTH,
Stephen Jackson
More information about the Qt-interest-old
mailing list