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. How to make the QGraphicsView re sizable by mouse?
Forum Updated to NodeBB v4.3 + New Features

How to make the QGraphicsView re sizable by mouse?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.7k 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.
  • M Offline
    M Offline
    Mohamed Hatem
    wrote on last edited by
    #1

    I want to allow the user to be able to resize the graphics view by mouse.
    something like the qt creator drawing window in the image below.

    0_1534434137097_6656a85e-8c0c-45d6-b3c5-58be6ba0cbd0-image.png

    I am searching for a while but can't find a way for doing it, so any help would be appreciated.
    I am thinking that I need to put it in a container that allows this behavior, but still not sure if this is a valid thinking or not and if valid what kind of container could it be.

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

      hi
      Maybe this be good starting point
      http://www.davidwdrell.net/wordpress/?page_id=46

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mohamed Hatem
        wrote on last edited by
        #3

        I already saw this link but it's working on adjusting the size of the item inside the view, not the view itself.
        thanks a lot.

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

          Hi and welcome to devnet,

          How are you handling that view within your application ?

          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
          1
          • M Offline
            M Offline
            Mohamed Hatem
            wrote on last edited by
            #5

            Hi,
            Thanks,
            please illustrate more the meaning of "how I am handling it" if I got it wrong.

            I am creating something like a drawing canvas so the QGraphicsView is in a splitter.
            to it's left a QTreeView in which I drag and drop items to the QGraphicsView and to it's right a QTreeView to show the properties of the items.
            I need the user to be able to set the size of the QGraphicsView which is in the middle of the splitter and to be allowed only to work within that area.
            it's nearly the same behavior as that in the QT creator
            what I'm doing right now is that I Just put the QGraphicsView in the Splitter and I set the Scene rectangle to some constant. but for sure this far away from the behavior needed.

            mrjjM 1 Reply Last reply
            0
            • M Mohamed Hatem

              Hi,
              Thanks,
              please illustrate more the meaning of "how I am handling it" if I got it wrong.

              I am creating something like a drawing canvas so the QGraphicsView is in a splitter.
              to it's left a QTreeView in which I drag and drop items to the QGraphicsView and to it's right a QTreeView to show the properties of the items.
              I need the user to be able to set the size of the QGraphicsView which is in the middle of the splitter and to be allowed only to work within that area.
              it's nearly the same behavior as that in the QT creator
              what I'm doing right now is that I Just put the QGraphicsView in the Splitter and I set the Scene rectangle to some constant. but for sure this far away from the behavior needed.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mohamed-Hatem

              Ah, I was too hasty.
              Missed it was the actual QGraphicsView widget you wanted to resize.
              This then :)
              https://wiki.qt.io/Widget-moveable-and-resizeable

              Alternative use http://doc.qt.io/qt-5/qrubberband.html
              and let user select area and then simply set the size directly.

              However, since a splitter is a layout, you will have to cheat and use
              setMaximumSize or similar to make it accept resizing the view.

              1 Reply Last reply
              2
              • M Offline
                M Offline
                Mohamed Hatem
                wrote on last edited by
                #7

                I will try both solutions, thanks alot.

                mrjjM 1 Reply Last reply
                1
                • M Mohamed Hatem

                  I will try both solutions, thanks alot.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Mohamed-Hatem
                  Which one worked best ?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mohamed Hatem
                    wrote on last edited by
                    #9

                    Well, I didn't try the second solution yet but the first solution worked like a charm, thanks alot.

                    1 Reply Last reply
                    1

                    • Login

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