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. QGraphicsScene --setting the position of items

QGraphicsScene --setting the position of items

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

    Hi all,I am trying to set the position of items in my scene but no matter what i try they stay in the center .The relevant part of my code is as follows:

    @

    scene=new MyScene(this);
    view =new QGraphicsView(this);
    view->setFixedSize(width(),height());
    view->setScene(scene);

    QGraphicsTextItem* mTextItem = scene->addText("boomba");
    mTextItem->setParent(view);
    mTextItem->setPos(QPointF(300,600));

    @

    I simply want to be in control of where those item go in my scene.The doc talks about mapping between scene and view but all I have tried has failed so far.
    Any hints /advice would be appreciated.

    Why join the navy if you can be a pirate?-Steve Jobs

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jake007
      wrote on last edited by
      #2

      Hi!

      If I remember correctly, you must set size to your scene(setSceneRect method).
      If not, scene will be dynamically extended while items are being added. First one will always be in centre.


      Code is poetry

      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