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. setDragMode not working when I use setSceneRect for the QGraphicsView

setDragMode not working when I use setSceneRect for the QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.1k 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
    Mohamed Hatem
    wrote on last edited by
    #1

    I am using "setSceneRect" to disable the autoscaling when I drag and drop items to the view.

    but when I use it I am not able to navigate through the scene using mouse dragging.
    What am I missing and if there is a suggestion of how to get the behavior needed?

    those are the 2 lines of code used for setting the scene and allowing DragMode:

    this->setSceneRect(-150,-150,300,300);
    
    this->setDragMode(QGraphicsView::ScrollHandDrag	);
    

    the output is that I am not able to navigate by mouse in the scene

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

      Hi,

      Just a quick idea: what about disabling the scroll bars ?

      setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
      setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
      

      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
        Mohamed Hatem
        wrote on last edited by
        #3

        I tried it but still, the problem exists.
        the workaround I am using right now is that I added some dummy invisible items to create an initial sceneRect without setting the sceneRect by my self so it's working but this is not a good practice at all, I need to know the right method for doing 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