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 :
{
static QFont font
("Times",
9);
int x = - this->vrptr->geometry().width(); //vrptr - pointer to QGraphicsView
int y= - (this->vrptr->geometry().height()/2);
static int yGrow = fn.height() - 3;
this->visualResultModel->clear();//visualResultModel is a QGraphicsScene
item= visualResultModel->addText(model->horizontalHeaderItem(0)->text(),font);
item->setPos(x,y);
for(int i=1;i<size;++i)
{
item= visualResultModel->addText(model->horizontalHeaderItem(i)->text(),font);
item->setPos(x,y+yGrow);
y=item->pos().y();
}
}
void Model::setUpGraphicScene(QStandardItemModel *model,int size)
{
static QFont font("Times",9);
int x = - this->vrptr->geometry().width(); //vrptr - pointer to QGraphicsView
int y= - (this->vrptr->geometry().height()/2);
QGraphicsItem * item;
static QFontMetrics fn (font);
static int yGrow = fn.height() - 3;
this->visualResultModel->clear();//visualResultModel is a QGraphicsScene
item= visualResultModel->addText(model->horizontalHeaderItem(0)->text(),font);
item->setPos(x,y);
for(int i=1;i<size;++i)
{
item= visualResultModel->addText(model->horizontalHeaderItem(i)->text(),font);
item->setPos(x,y+yGrow);
y=item->pos().y();
}
}
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
Bookmarks