Results 1 to 12 of 12

Thread: Position of Items in QGraphicsScene/QGraphicsView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    6
    Thanks
    2

    Question Position of Items in QGraphicsScene/QGraphicsView

    Hello,

    I have a problem with the position of Items in QGraphicsScenes.

    I wrote this simple program for testing, I made the ui with the designer:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. Form form;
    6.  
    7.  
    8. scene.setSceneRect(0, 0, form.graphicsView->width(), form.graphicsView->height());
    9.  
    10. scene.addRect(0, 0, 10, 10, QPen(), QBrush(QColor(Qt::black)));
    11.  
    12. form.graphicsView->setScene(&scene);
    13. form.graphicsView->fitInView(scene.sceneRect());
    14.  
    15. form.show();
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    When I run this program the RectItem somewhere in the view, not at the position (0,0).

    Where is the error in this code, I thought fitInView() manipulates the view in a way that the sceneRect is scaled to the right size.
    Attached Images Attached Images

Similar Threads

  1. Replies: 2
    Last Post: 12th June 2009, 10:55
  2. Some menubar items can not be clicked
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 00:26
  3. Light items for the graphicsView
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 1st November 2007, 18:51
  4. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  5. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.