Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Resize from within resizeEvent don't stick

    General and Desktop
    3
    9
    1828
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Misty River last edited by

      Hi, I am calling resize() from within resizeEvent but when I release the mouse button when I'm done dragging the window reverts back to the original size it had before I started resizing.... anyone knows why and how to change that?

      1 Reply Last reply Reply Quote 0
      • A
        andreyc last edited by

        Could you show the source of your resizeEvent()?

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

          Before going further in that direction, read the warning "here":http://qt-project.org/doc/qt-5/qwidget.html#size-prop

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • M
            Misty River last edited by

            @void Widget::resizeEvent(QResizeEvent * event)
            {
            QSize size = event->size();
            QSize oldSize = event->oldSize();

            int height = size.height();
            int width = size.width();
            int oldHeight = oldSize.height();
            int oldWidth = oldSize.width();
            
            if (height != oldHeight && width == oldWidth) {
                width = height;
                resize(width, height);
            }
            else if (width != oldWidth && height == oldHeight) {
                height = width;
                resize(width, height);
            }
            

            }
            @

            1 Reply Last reply Reply Quote 0
            • M
              Misty River last edited by

              try it.. the flickers seem to be caused by the fact that the underlying painting mechanism for top-level windows always go back painting the original size.. and when you release the mouse it reverts back again... what controls the painting of top-level widgets?!

              1 Reply Last reply Reply Quote 0
              • A
                andreyc last edited by

                It works in Gnome-flashback environment. It is gnome 3 with gnome 2 look.
                There are some artifacts caused by calling resize from resizeEvent.

                I think you should consider the warning that SGaist pointed.

                If you need to resize a window as a square then resizeEvent() is not good approach because it is called when resize is already done.

                1 Reply Last reply Reply Quote 0
                • M
                  Misty River last edited by

                  Well if it does work under different GUI manager then it's probably Windows window manager that is wacky... is there like a way to know on mouse click that the window resize border are being grabbed or something like that?

                  1 Reply Last reply Reply Quote 0
                  • A
                    andreyc last edited by

                    You may try to use "Event filters":http://qt-project.org/doc/qt-5/eventsandfilters.html#event-filters

                    But since Qt does not control titlebar, I think a frame around window is also not under Qt control, so it is possible that you will not get any events before resize is finished.

                    In this case you may try to implement frame and resize by yourself.
                    Something like in "this":http://qt-project.org/faq/answer/how_can_i_handle_events_in_the_titlebar_and_change_its_color_etc example.

                    1 Reply Last reply Reply Quote 0
                    • M
                      Misty River last edited by

                      I have already tried filtering events. But the second option you pointed out seems to me like a really good idea I'll try this one out.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post