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. resizeable rubber band with QSizeGrip
Forum Updated to NodeBB v4.3 + New Features

resizeable rubber band with QSizeGrip

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 964 Views 2 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.
  • P Offline
    P Offline
    pmh4514
    wrote on last edited by
    #1

    Hi - I'm using Qt 5.14 on Win10 x64

    Trying to implement a resizeable "rubber band" for ROI selection over an image, using what I found here as the accepted answer on StackOverflow:

    https://stackoverflow.com/questions/19066804/implementing-resize-handles-on-qrubberband-is-qsizegrip-relevant/19067132

    My code is exactly as in the example.

    Generally it works as I expect. However, in the above example, the size grip in the upper left is pointing up and to the left (and can presumably adjust the ROI up and to the left) and the one in the lower right is pointing down and to the right and can adjust the ROI down/right.

    My lower right QSizeGrip works and looks as expected and I can use it to expand my ROI down/right as I'd expect. But the one in the upper left is not painted pointing up/left like it is in the stackoverflow example, it looks the same as the one in the lower right. Dragging it left/right adjusts my ROI as expected, but dragging it up/down is exactly the same behavior as dragging the lower right sizegrip, where the upper left corner of the ROI is anchored, rather than actually resizing it in that direction.

    I realize the stack overflow example is quite old and against an older version of Qt, but does anybody know how I can make it so the two drag handles can expand the ROI in both directions as expected?
    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you provide a minimal compilable example that shows the behaviour you have ? There might be something unrelated to the stack overflow code happening.

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

      Pl45m4P 1 Reply Last reply
      0
      • P Offline
        P Offline
        pmh4514
        wrote on last edited by
        #3

        Good idea. Of course, putting together a simple empty QMainWindow project with a single QLabel taking on the rubber band functionality, it works as I'd expect it to. Meaning the behavior is due to something elsewhere in my real project.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That's a good news.

          Then I would disable all widgets that are not related to your rubber band and gradually add them back until things get wrong.

          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
          • P Offline
            P Offline
            pmh4514
            wrote on last edited by
            #5

            Yah I started looking at how I was setting it up and controlling it - the GUI interaction of this particular app positions the rubber band automatically at previously user-defined positions. I was calling setGeometry on it with a QRect whose coordinates were reversed. (interestingly to no visual detriment.) Now that I've changed that, the QSizeGrip handles do function as expected, I can resize up/left just as well as down/right.. The upper left arrow itself is not pointing the correct direction (up/left) but at least now it's behaving as expected.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then there must be one last glitch hiding.

              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
              • P Offline
                P Offline
                pmh4514
                wrote on last edited by
                #7

                I'll have to dig into the QSizeGrip code to see what determines its orientation

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  There's a method in the private implementation of the class that determines that based on the position of the grip.

                  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
                  • P Offline
                    P Offline
                    pmh4514
                    wrote on last edited by
                    #9

                    yah I'm seeing that.. Interestingly it's being painted in the correct spot (and now behaving as such) but it's being painted as if it's the lower-right

                    1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Hi,

                      Can you provide a minimal compilable example that shows the behaviour you have ? There might be something unrelated to the stack overflow code happening.

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on last edited by
                      #10

                      @SGaist said in resizeable rubber band with QSizeGrip:

                      Can you provide a minimal compilable example that shows the behaviour you have ?

                      This in Top 3 of "solutions which will fix your Qt problem" 😂😂
                      RubberDuck Debugging ;-)


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        pmh4514
                        wrote on last edited by
                        #11

                        Indeed it is!

                        I'm going to mark this solved. I haven't figured out yet why my TL corner is painting as if LR, but that's beside the point I think.

                        1 Reply Last reply
                        0

                        • Login

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