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. Unwanted resize QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

Unwanted resize QGraphicsScene

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.2k 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.
  • ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by
    #1

    Hello!

    I am working with a QGraphicsView and I have a little problem. This is my example:

    0_1521543667899_6e1f4c1b-0fb2-4afc-b7c4-2e4c4891dcc3-image.png

    The camera image is an item that I can move but, when I move it out of the scene, the scene resizes and I don't want that:

    0_1521543739527_554ee3cf-1460-4704-a08e-9e45cf7cf01f-image.png

    How can I do to not allow this resize?

    Thank you very much!

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

      Hi,

      What should happen when you move the camera out of the scene ?

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

      ivanicyI 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        What should happen when you move the camera out of the scene ?

        ivanicyI Offline
        ivanicyI Offline
        ivanicy
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What should happen when you move the camera out of the scene ?

          ivanicyI Offline
          ivanicyI Offline
          ivanicy
          wrote on last edited by
          #4

          @SGaist It must be like a "wall". It mustn't allow the movement out of the scene

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

            Then it looks like you should do some collision detection on where you won't need your camera to go then remove them.

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

            ivanicyI 1 Reply Last reply
            0
            • SGaistS SGaist

              Then it looks like you should do some collision detection on where you won't need your camera to go then remove them.

              ivanicyI Offline
              ivanicyI Offline
              ivanicy
              wrote on last edited by
              #6

              @SGaist Ouch, I thought it could have a solution more "automatic" like a flag or something like this. I just want to put the widget on the edge of the window when I want to get it out of it.

              Thank you for your time!

              1 Reply Last reply
              0
              • ivanicyI Offline
                ivanicyI Offline
                ivanicy
                wrote on last edited by
                #7

                Ok, I found a solution that could be useful. Only with this line (view is the QGraphicsView, and item, the QGraphicsPixmapItem that I use of background):

                view.setSceneRect(0, 0, item->boundingRect().width(), item->boundingRect().height());
                

                This solution sets the scene and, although the widget can exit it, it does not resize it.

                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