Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    [Solved]Qt QGraphicsItem - always in center of QGraphicsView

    General and Desktop
    2
    3
    9420
    Loading More Posts
    • 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
      Peppy last edited by

      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 Reply Quote 0
      • Z
        ZapB last edited by

        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 Reply Quote 0
        • P
          Peppy last edited by

          Yes it works properly now, thanks.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post