Hello all!
I have problem with changing position for QGraphicsTextItem's on QGraphicsView/Scene. I want pos them at upper left corner, here is the source of my method :


Qt Code:
  1. void Model::setUpGraphicScene(QStandardItemModel *model,int size)
  2. {
  3. static QFont font("Times",9);
  4. int x = - this->vrptr->geometry().width(); //vrptr - pointer to QGraphicsView
  5. int y= - (this->vrptr->geometry().height()/2);
  6. QGraphicsItem * item;
  7. static QFontMetrics fn (font);
  8. static int yGrow = fn.height() - 3;
  9. this->visualResultModel->clear();//visualResultModel is a QGraphicsScene
  10. item= visualResultModel->addText(model->horizontalHeaderItem(0)->text(),font);
  11. item->setPos(x,y);
  12. for(int i=1;i<size;++i)
  13. {
  14. item= visualResultModel->addText(model->horizontalHeaderItem(i)->text(),font);
  15. item->setPos(x,y+yGrow);
  16. y=item->pos().y();
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

here is result :

i.e. there is scrolling appears, why?
Thanks.
And sorry for my bad english