Important: Please read the Qt Code of Conduct -

Manage resize events in Qt-Quick

  • Hi to all

    I need to manage some state changes in objects contained in the main rectangel item (formerly named "screen").

    I saw that in QML only keyboard and mouse generate formal events. Is there a ways to intercept when the size of the window changes in QML or I need to create the object in C++ and communicate with QML script?

    (I hope I had been clear)

  • Are you using a QDeclarativeView? If so, it has different modes for resizing. Does that help?

  • Hi Andre, help so and so. I use QDelcarativeView, sure.
    (I was too sure I was not so clear ... sorry). The window will be resized by the user: so the main item has the same size, obviously. Thus when the user maximeze or resize the appplication windows (on the desktop) I will to know that it has changed, so change a state that change sizes, some properties and position of all the childs that are inside the window and not all can be anchored together.
    This is the question.

  • Well, did you look into "this": piece of documentation?

    It explains that you can make QDeclarativeView automatically resize the root item of your QML, thus making automatic resizing of your layout possible.

  • Thank you Andre, this is a field I don't know so much. It is useful for me but unfortunately not in this case. Here I need to know when the window changes size, to do some stuff in several piece of the program (QML) depending on the screen size, new dimensions etc. What I need is possible that is a way to intercept the window resize event.

    A way I have in mind is to remove (again) the windows control, substituting with a custom piece on the interface, or = probably most correct = manage the resize event in the c++ code and communicate this to the qml sources.

Log in to reply