Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.4.0
-
None
Description
QTabBar does not invalidate geometry when tabs are inserted or removed whilst hidden
QTabBarPrivate::refresh() is called to update a QTabBar when tabs are inserted or removed. When the widget is hidden, it sets a boolean (layoutDirty) to true and returns. This means that the parent widget's layout is not notified about the possible geometry change.
In Qt 4.3 and prior this was not a problem because the tab bar layout would be recalculated whenever QTabBar::sizeHint() was called. In Qt 4.4 however the QWidgetItemV2 in the layout caches the size hint information, so QTabBar::sizeHint() is not always called after tabs are inserted or removed because the layout is unaware that its cached size hint is no longer valid.
If the tab bar is empty when QTabBar::sizeHint() is first called it will return a height of 0 and so, since QTabBar::sizeHint() is not called again, the tab bar will never be shown.
The patch below fixes the problem by calling always calling updageGeometry() in QTabBarPrivate::refresh()
Index: qtabbar.cpp
===================================================================
— qtabbar.cpp (revision 796858)
+++ qtabbar.cpp (working copy)
@@ -533,8 +533,8 @@
layoutTabs();
makeVisible(currentIndex);
q->update();
- q->updateGeometry();
}
+ q->updateGeometry();
}
/*!