Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.0 Beta1
-
None
-
afbad00a4d9ff28967ca15e0f9029925e86f2cf4
Description
Take the qquickwidget example and replace main.cpp with this:
#include <QQuickWidget> #include <QtWidgets> class HideShow : public QObject { Q_OBJECT public: QWidget *subject; HideShow(QWidget *subject, int interval) : QObject(subject), subject(subject) { startTimer(interval); } void timerEvent(QTimerEvent *) { if (subject->isVisible()) { subject->hide(); } else { subject->show(); } } }; int main(int argc, char **argv) { QApplication app(argc, argv); QWidget *toplevel = new QWidget; QVBoxLayout *groupLayout = new QVBoxLayout; QUrl source("qrc:quickwidget/rotatingsquare.qml"); QQuickWidget *above = new QQuickWidget; above->setResizeMode(QQuickWidget::SizeRootObjectToView); above->setSource(source); above->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); above->setFixedHeight(50); groupLayout->addWidget(above); QQuickWidget *w = new QQuickWidget; w->setResizeMode(QQuickWidget::SizeRootObjectToView); w->setSource(source); w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); groupLayout->addWidget(w); QQuickWidget *below = new QQuickWidget; below->setResizeMode(QQuickWidget::SizeRootObjectToView); below->setSource(source); below->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); below->setFixedHeight(50); groupLayout->addWidget(below); new HideShow(w, 3000); toplevel->setMinimumHeight(170); toplevel->setLayout(groupLayout); toplevel->show(); return app.exec(); } #include "main.moc"
When the central widget is hidden the two others move to the middle. When it's shown again they don't move back. Now compare that with:
#include <QQuickWidget> #include <QtWidgets> class HideShow : public QObject { Q_OBJECT public: QWidget *subject; HideShow(QWidget *subject, int interval) : QObject(subject), subject(subject) { startTimer(interval); } void timerEvent(QTimerEvent *) { if (subject->isVisible()) { subject->hide(); } else { subject->show(); } } }; int main(int argc, char **argv) { QApplication app(argc, argv); QWidget *toplevel = new QWidget; QVBoxLayout *groupLayout = new QVBoxLayout; QLCDNumber *above = new QLCDNumber; above->display(1337); above->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); above->setFixedHeight(50); groupLayout->addWidget(above); QLCDNumber *w = new QLCDNumber; w->display(1338); w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); groupLayout->addWidget(w); QLCDNumber *below = new QLCDNumber; below->display(1339); below->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); below->setFixedHeight(50); groupLayout->addWidget(below); new HideShow(w, 3000); toplevel->setMinimumHeight(170); toplevel->setLayout(groupLayout); toplevel->show(); return app.exec(); } #include "main.moc"
The LCD widgets move correctly when the layout changes.
Attachments
Issue Links
- is required for
-
QTBUG-36935 various problems when trying to use QQuickWidget in QML profiler
- Closed