Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Resize from within resizeEvent don't stick
Forum Updated to NodeBB v4.3 + New Features

Resize from within resizeEvent don't stick

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.3k Views 1 Watching
  • 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 Offline
    M Offline
    Misty River
    wrote on 22 Jul 2014, 21:06 last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andreyc
      wrote on 22 Jul 2014, 21:22 last edited by
      #2

      Could you show the source of your resizeEvent()?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 22 Jul 2014, 21:39 last edited by
        #3

        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
        0
        • M Offline
          M Offline
          Misty River
          wrote on 23 Jul 2014, 05:35 last edited by
          #4

          @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
          0
          • M Offline
            M Offline
            Misty River
            wrote on 23 Jul 2014, 05:37 last edited by
            #5

            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
            0
            • A Offline
              A Offline
              andreyc
              wrote on 23 Jul 2014, 19:40 last edited by
              #6

              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
              0
              • M Offline
                M Offline
                Misty River
                wrote on 23 Jul 2014, 20:27 last edited by
                #7

                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
                0
                • A Offline
                  A Offline
                  andreyc
                  wrote on 24 Jul 2014, 15:33 last edited by
                  #8

                  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
                  0
                  • M Offline
                    M Offline
                    Misty River
                    wrote on 24 Jul 2014, 20:29 last edited by
                    #9

                    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
                    0

                    1/9

                    22 Jul 2014, 21:06

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved