Results 1 to 3 of 3

Thread: View,Scene and RectItem

  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default View,Scene and RectItem

    i have a very basic problem ,i am trying to draw a rectangle in my widget at a certain position but it wont draw ,below is the code ,
    Qt Code:
    1. aWidget::aWidget(QWidget *parent)
    2. : QWidget(parent)
    3. {
    4.  
    5. ....
    6. matrixScene = new QGraphicsScene();
    7. matrixView = new QGraphicsView(matrixScene);
    8. DrawMatrix();
    9. ..
    10. }
    11. void aWidget::DrawMatrix()
    12. {
    13. squares.setRect(1000,1000,50,50);
    14. //squares = new QGraphicsRectItem();
    15. //squares = matrixScene.addRect(QRectF(10,50,100,100));
    16. matrixScene->addItem(&squares);
    17. matrixView->setScene(matrixScene);
    18. }
    19. #include <QtGui>
    20. #include <QWidget>
    21. #include "ui_ninesilicawidget.h"
    22.  
    23. class aWidget : public QWidget
    24. {
    25. Q_OBJECT
    26. ...
    27. QGraphicsView *matrixView;
    28. QGraphicsScene *matrixScene;
    29. Ui::NineSilicaWidgetClass ui;
    30. ..
    31. ...
    32. };
    33.  
    34. #endif // NINESILICAWIDGET_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: View,Scene and RectItem

    Is your sceneRect set properly ? May be the item is too far away and its not being drawn ?
    Also about the design, why dont you inherit from QGraphicsView itself ?

    Ohh wait.. where did you show the view ???

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: View,Scene and RectItem

    Is your sceneRect set properly ?
    More likely the problem is about this issue..

Similar Threads

  1. QGraphicsItem .. Scene .. View question?
    By DirtyBrush in forum Qt Programming
    Replies: 21
    Last Post: 19th October 2010, 09:12
  2. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  3. Graphics View - Scene & Item hierarchy
    By mooreaa in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2008, 23:49
  4. how to zoom out item in View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 7
    Last Post: 28th December 2007, 10:24
  5. Scrolling problem with background using View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 5
    Last Post: 22nd October 2007, 08:19

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.