diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-04-22 13:40:44 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2010-04-22 13:40:44 (GMT) |
commit | 4780f94e391b5e881497c5228661dead42c821fa (patch) | |
tree | 2e60b5f8a599e8c927cad3d218d0126262cfdbea /src/gui/widgets/qsizegrip.cpp | |
parent | 12eac6fa53680b5c7a6c898749a4ac0d3c427c18 (diff) | |
download | Qt-4780f94e391b5e881497c5228661dead42c821fa.zip Qt-4780f94e391b5e881497c5228661dead42c821fa.tar.gz Qt-4780f94e391b5e881497c5228661dead42c821fa.tar.bz2 |
Implement heightForWidth support for QTabWidget and QStackedWidget.
The problem was simply that QTabWidget does not have a layout (it
does manual layouting, and since that the heightForWidth implementation
it inherits from QWidget require that the widget has a layout it will
not work and it always returned -1 for QTabWidget). The solution is then
to reimplement heightForWidth().
Unfortunately the patch has several workarounds for BIC:
1. QWidget::hasHeightForWidth() should really have been virtual. Instead
we add the virtual QWidgetPrivate::hasHeightForWidth().
Since this is a workaround/bugfix for QTabWidget we decided to keep
QWidget::hasHeightForWidth() internal for now.
2. We cannot reimplement a virtual function in QStackedLayout.
We therefore fix QStackedWidget by subclassing QStackedLayout and
reimplement the virtual functions in the subclass.
This is not an ideal fix, but improves QTabWidget and QStackedWidget
wrt height for width.
Task-number: QTBUG-7792
Reviewed-by: Paul
Reviewed-by: Olivier
Diffstat (limited to 'src/gui/widgets/qsizegrip.cpp')
-rw-r--r-- | src/gui/widgets/qsizegrip.cpp | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp index c9d613a..b5b611c 100644 --- a/src/gui/widgets/qsizegrip.cpp +++ b/src/gui/widgets/qsizegrip.cpp @@ -78,15 +78,6 @@ static QWidget *qt_sizegrip_topLevelWidget(QWidget* w) return w; } -static inline bool hasHeightForWidth(QWidget *widget) -{ - if (!widget) - return false; - if (QLayout *layout = widget->layout()) - return layout->hasHeightForWidth(); - return widget->sizePolicy().hasHeightForWidth(); -} - class QSizeGripPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSizeGrip) @@ -318,7 +309,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) #ifdef Q_WS_X11 // Use a native X11 sizegrip for "real" top-level windows if supported. if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE); @@ -340,7 +331,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) } #endif // Q_WS_X11 #ifdef Q_WS_WIN - if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { uint orientation = 0; if (d->atBottom()) orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT; @@ -429,12 +420,12 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e) #ifdef Q_WS_X11 if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) + && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) return; #endif #ifdef Q_WS_WIN if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId() - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { MSG msg; while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); return; |