Results 1 to 1 of 1

Thread: why item corrdinate is incorrect inside QgraphicsScene?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Question why item corrdinate is incorrect inside QgraphicsScene?

    Hi All,


    Qt Code:
    1. view_ = new QGraphicsView(this);
    2. qDebug()<<view_->horizontalScrollBar()->height(); //30
    3.  
    4. view_->resize(
    5. 200 + view_->horizontalScrollBar()->height(),
    6. 200+view_->horizontalScrollBar()->height()
    7. );
    8. scene_ = new QGraphicsScene(0,0,200,200,this);
    9. view_->setScene(scene_);
    10.  
    11. QGraphicsRectItem *rect = new QGraphicsRectItem(QRect(0,0,20,20));
    12. rect->setBrush(Qt::red);
    13. rect->setPos(0,0);
    14. scene_->addItem(rect);
    15.  
    16.  
    17. QPushButton *bt=new QPushButton("ok",this);
    18. bt->move(15,15);
    To copy to clipboard, switch view to plain text mode 

    since default alignment of scene is center,
    and the view's size is (230,230)
    the scene's size is (200,200)
    so I guess ,the rect should at QPoint(15,15),
    I place a button at QPoint(15,15) to check whether the button can cover the rect totally,
    but from the attached pic ,we can see there is a gap between them ,
    I was wondering why, any ideas about it?

    Thank advance for your help.
    Best regards,
    hb
    Attached Images Attached Images

Similar Threads

  1. Video Rendering fails inside QGraphicsScene
    By sschilz in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2010, 21:29
  2. QFrame with border-radius inside QGraphicsScene
    By DeRatizator in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2010, 08:39
  3. Incorrect option.rect in custom item delegate
    By Jarvis in forum Qt Programming
    Replies: 0
    Last Post: 16th April 2010, 23:48
  4. QGLWidget inside QGraphicsScene/View
    By h123 in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2009, 08:46
  5. Replies: 4
    Last Post: 11th July 2007, 04:21

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