Results 1 to 4 of 4

Thread: Centralizing various GraphicsItem in QGraphicsView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Sep 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Centralizing various GraphicsItem in QGraphicsView

    The problem scenario is below:

    1. A list of polygons are displayed in the left side of the widget.
    2. On the right side of the widget a preview area is there with QGraphicsView widget..
    3. The user can select a polygon from the left side and the selected polygon is displayed in
    the right side preview area...
    4. The selected polygons are scattered at different points of QGraphicsView.
    5. I require that the polygons should be drawn in correct order as you can see in the attachement AFter_Centralization.jpg.

    I am adding the polygon like below

    Qt Code:
    1. DrawPolygon(int xOffset, int yOffset)
    2. {
    3. QGraphicsView *ptrGraphicsView = new QGraphicsView();
    4. QGraphicsScene *polyScene = new QGraphicsScene();
    5. QVector <QPointF> vctPoints;
    6. for(int i=xOffset; i<10; i++)
    7. {
    8. for(j=yOffset; j<10; j++)
    9. {
    10. vctPoints.append(QPointF(i*50,j*50));
    11. }
    12. }
    13. QPolygon *polygon = new QPolygon(vctPoints);
    14. polyScene->addPolygon(polygon);
    15. ptrGraphisView->setScene(polyScene);
    16. }
    To copy to clipboard, switch view to plain text mode 

    The above function draws polygon considering different offset values... and so the polygons get scattered in the QGV...

    I want to place the scattered polygons in a central axis...

    Regards
    Ranna
    Last edited by wysota; 16th June 2009 at 10:48. Reason: missing [code] tags

Similar Threads

  1. Replies: 21
    Last Post: 3rd April 2009, 12:22
  2. Replies: 0
    Last Post: 5th March 2009, 06:54
  3. Replies: 2
    Last Post: 26th February 2009, 10:12
  4. QGraphicsView and embeded widgets
    By bunjee in forum Qt Programming
    Replies: 10
    Last Post: 12th October 2008, 07:43
  5. Problem determining size of QGraphicsView
    By Bocki in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 14:54

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.