Qt-interest Archive, February 2007
Complete rectangle of QTabBar ?
Message 1 in thread
Hello all,
the tabbed GUI implementation in Qt is a joyful experience, at least
in comparison with CTabCtrl of MFC's fame. However, i am trying to do
a simple thing: i want the tabs to stretch to evenly occupy whole bar
width (or height in case of vertical TabPosition). As far as i know,
QTabWidget represents the whole rectangle of tabbed windows, i.e. tab
bar itself and the child widgets too. So i have overriden QTabBar and
expected it to know the geometry of the tab bar (that is, the whole
slim rectangle occupied by tab bookmarks). So far, i haven't found a
way to reach it. I have tried rect() and geometry() in various
overriden resizeEvents, paintEvents and the QTabWidget "this" as well,
but everybody is reporting just the current properties of each tab
bookmark. I want to get the whole width and divide it by count() of
tabs.
My temporary kludge is getting the width() of QTabWidget's resizeEvent
and setting it down to the assigned subclassed QTabBar. There surely
is more elegant way, isn't it?
Best regards,
Pavel Zdenek
--
[ signature omitted ]
Message 2 in thread
> There surely is more elegant way, isn't it?
I did this by reimplementing QTabBar::tabSizeHint() and ::paintEvent()
(for repainting missing pixels). It's surely an inelegant, but working
solution.
I already made this a suggestion, which was rejected :-( See Tasktracker
issue # 116563.
Martin
--
[ signature omitted ]
Message 3 in thread
On 28.02.07 10:29:34, Pavel Zdenek wrote:
> Hello all,
>
> the tabbed GUI implementation in Qt is a joyful experience, at least
> in comparison with CTabCtrl of MFC's fame. However, i am trying to do
> a simple thing: i want the tabs to stretch to evenly occupy whole bar
> width (or height in case of vertical TabPosition). As far as i know,
> QTabWidget represents the whole rectangle of tabbed windows, i.e. tab
> bar itself and the child widgets too. So i have overriden QTabBar and
> expected it to know the geometry of the tab bar (that is, the whole
> slim rectangle occupied by tab bookmarks). So far, i haven't found a
> way to reach it. I have tried rect() and geometry() in various
> overriden resizeEvents, paintEvents and the QTabWidget "this" as well,
> but everybody is reporting just the current properties of each tab
> bookmark. I want to get the whole width and divide it by count() of
> tabs.
I might be wrong, but I think for a widget like this:
----------------------
| tab1 | tab2 | tab3 |
---------------------------------------------
| |
| |
| |
| |
| |
| |
| |
---------------------------------------------
The tabbar is only as wide as the 3 tabs, not as wide as the
widget-area, because it uses the sizehint from the tabs.
So overriding tabSizeHint should do it, unfortunately you have to
provide a setQTabWidgetWidth method to store the width that the
qtabwidget is going to use on your qtabbar subclass so you can calculate
the tabs width based on that. This means you need to subclass both
QTabBar and QTabWidget, overriding resizeEvent of QTabWidget and doing
the setQTabWidgetWidth() on your new QTabBar subclass.
Andreas
--
[ signature omitted ]