Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
4.8.5, 5.2.0
-
None
Description
Setting heightForWidth() to true does not work with QMdiSubWindow. Tried setting it both to QMdiSubWindow and to the containing widget. Here is an example, which shows how it works in plain QWidget but not when placed to QMdiArea.
#include <QApplication> #include <QWidget> #include <QDebug> #include <QVBoxLayout> #include <QMdiArea> #include <QMainWindow> #include <QMdiSubWindow> class OwnSubWindow : public QMdiSubWindow { mutable int m_ctr; public: OwnSubWindow(QWidget *parent = 0) : QMdiSubWindow(parent), m_ctr(0) { QSizePolicy p(sizePolicy()); p.setHeightForWidth(true); setSizePolicy(p); } int heightForWidth(int width) const { qDebug()<<"heightforwidth "<<m_ctr; m_ctr ++; qApp->postEvent(const_cast<OwnSubWindow*>(this), new QEvent(QEvent::UpdateRequest)); return qMax(width*2, 100); } QSize sizeHint() const { return QSize(300, heightForWidth(300)); } }; class Widget : public QWidget { mutable int m_ctr; public: Widget(QWidget *parent = 0) : QWidget(parent), m_ctr(0) { QSizePolicy p(sizePolicy()); p.setHeightForWidth(true); setSizePolicy(p); } int heightForWidth(int width) const { qDebug()<<"heightforwidth "<<m_ctr; m_ctr ++; QApplication::postEvent(const_cast<Widget*>(this), new QEvent(QEvent::UpdateRequest)); return qMax(width*2, 100); } QSize sizeHint() const { return QSize(300, heightForWidth(300)); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow w1; QMdiArea *mdiArea = new QMdiArea(); mdiArea->addSubWindow(new OwnSubWindow); mdiArea->addSubWindow(new Widget); w1.setCentralWidget(mdiArea); w1.show(); QWidget w; QVBoxLayout * l = new QVBoxLayout(&w); l->addWidget(new Widget); w.show(); return a.exec(); }
Attachments
Issue Links
- relates to
-
QTBUG-36318 Platform plugin does not respect HeightForWidth
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-36220 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
98274,7 | Implement heightForWidth(). | 5.4 | qt/qtbase | Status: MERGED | +2 | 0 |
125746,2 | QPlatformWindow: Extract static method for closestAcceptableGeometry(). | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |