Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[SOLVED] Problem with resizeEvent in QQuickView with SizeRootObjectToView on

$
0
0
Hello all, To show the problem, here is a minimalist program : main.cpp #include <QtGui/QGuiApplication> #include <QQuickView>   class View : public QQuickView { public:     View() {} };   int main(int argc, char *argv[]) {     QGuiApplication app(argc, argv);     View qv;     qv.setSource(QUrl::fromLocalFile("qml/resize/main.qml"));     qv.setWidth(300);     qv.setHeight(500);     qv.setResizeMode(QQuickView::SizeRootObjectToView);     qv.show();     return app.exec(); } main.qml import QtQuick 2.0   Item {     id : root     Rectangle {         color: "red"         anchors.fill: parent         Text {             text: "Height : " + root.height + " and width : " + root.width             anchors.centerIn: parent         }     } } Here, no problem. When i resize the windows, the red rectangle follows the window and the text show the size of the window. Now i’m introcing the resizeEvent. main.cpp #include <QtGui/QGuiApplication> #include <QQuickView>   class View : public QQuickView { public:     View() {} protected:     void resizeEvent(QResizeEvent * ev){} };   int main(int argc, char *argv[]) {     QGuiApplication app(argc, argv);     View qv;     qv.setSource(QUrl::fromLocalFile("qml/resize/main.qml"));     qv.setWidth(300);     qv.setHeight(500);     qv.setResizeMode(QQuickView::SizeRootObjectToView);     qv.show();     return app.exec(); } main.qml import QtQuick 2.0   Item {     id : root     Rectangle {         color: "red"         anchors.fill: parent         Text {             text: "Height : " + root.height + " and width : " + root.width             anchors.centerIn: parent         }     } } Here, the problem is that the size of the rectangle doe’nt change with the resizing. I’m looking in the source code of Qt 5.1 in the funtion that i have overload (resizeEvent), there nothing in the functions. So what ? Have i miss something ? Is thit a bug of Qt ? Thanks

Viewing all articles
Browse latest Browse all 4972

Latest Images

Trending Articles



Latest Images