diff --git a/include/wx/qt/window.h b/include/wx/qt/window.h index ace2a71711..77eca2de6f 100644 --- a/include/wx/qt/window.h +++ b/include/wx/qt/window.h @@ -230,6 +230,11 @@ private: QScrollBar *m_horzScrollBar; // owned by m_qtWindow when allocated QScrollBar *m_vertScrollBar; // owned by m_qtWindow when allocated + // Return the viewport of m_qtContainer, if it's used, or just m_qtWindow. + // + // Always returns non-null pointer if the window has been already created. + QWidget *QtGetClientWidget() const; + QScrollBar *QtGetScrollBar( int orientation ) const; QScrollBar *QtSetScrollBar( int orientation, QScrollBar *scrollBar=NULL ); diff --git a/src/qt/window.cpp b/src/qt/window.cpp index c67e9606ea..21d9b6f1ab 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -582,6 +582,23 @@ void wxWindowQt::DoGetTextExtent(const wxString& string, int *x, int *y, int *de *externalLeading = fontMetrics.lineSpacing(); } +QWidget *wxWindowQt::QtGetClientWidget() const +{ + QWidget *qtWidget = NULL; + if ( m_qtContainer != NULL ) + { + qtWidget = m_qtContainer->viewport(); + } + + if ( qtWidget == NULL ) + { + // We don't have scrollbars or the QScrollArea has no children + qtWidget = GetHandle(); + } + + return qtWidget; +} + /* Returns a scrollbar for the given orientation, or NULL if the scrollbar * has not been previously created and create is false */ QScrollBar *wxWindowQt::QtGetScrollBar( int orientation ) const @@ -957,7 +974,8 @@ void wxWindowQt::DoSetSize(int x, int y, int width, int height, int sizeFlags ) void wxWindowQt::DoGetClientSize(int *width, int *height) const { - QRect geometry = GetHandle()->geometry(); + QWidget *qtWidget = QtGetClientWidget(); + const QRect geometry = qtWidget->geometry(); if (width) *width = geometry.width(); if (height) *height = geometry.height(); } @@ -965,7 +983,7 @@ void wxWindowQt::DoGetClientSize(int *width, int *height) const void wxWindowQt::DoSetClientSize(int width, int height) { - QWidget *qtWidget = GetHandle(); + QWidget *qtWidget = QtGetClientWidget(); QRect geometry = qtWidget->geometry(); geometry.setWidth( width ); geometry.setHeight( height );