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. [Solved]Qt QGraphicsItem - always in center of QGraphicsView
QtWS25 Last Chance

[Solved]Qt QGraphicsItem - always in center of QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.8k Views
  • 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
    Peppy
    wrote on last edited by
    #1

    Hi? I am back with this issue: I've got inherited class QGraphicsItem, which is added & displayed on QGraphicsView, but it's always at center (I can't move with it)...How to solve this problem?

    I've tried QGraphicsItem->moveBy(...) but didn't work...

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Sounds like you are not explicitly setting a sceneRect on your scene. If you do not explicitly set a scene rect then the QGV framework calculates one for you and with just one item it will appear as if that item is centered in the view.

      Try calling QGraphicsScene::setSceneRect() with a suitable boundng rectangle.

      If you wish to move an item with the mouse then you need to enable the QGraphicsItem::ItemIsMovable flag too.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

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

        Yes it works properly now, thanks.

        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