This is my code
I'd like to setPos() but with the ui->graphicsView->setAlignment(Qt::AlignTop|Qt::AlignLeft); all the items are at left I can only change setPos(x,y); y value
How can I do to use setPos() ?
text->setHtml("100");
text2->setHtml("100");
line->setLine(0, 0, 50, 0);
text3->setHtml("200");
sc->addItem(text);
sc->addItem(text2);
sc->addItem(text3);
sc->addItem(line);
text->setPos(30, 0);
text2->setPos(30, 20);
text3->setPos(30, 45);
line->setPos(30, 40);
ui->graphicsView->setScene(sc);
ui->graphicsView->setAlignment(Qt::AlignTop|Qt::AlignLeft);
ui->graphicsView->update();
QString txt=ui->lineEdit->text();
QGraphicsScene * sc=new QGraphicsScene();
QGraphicsTextItem * text=new QGraphicsTextItem();
text->setHtml("100");
QGraphicsTextItem * text2=new QGraphicsTextItem();
text2->setHtml("100");
QGraphicsLineItem * line=new QGraphicsLineItem();
line->setLine(0, 0, 50, 0);
QGraphicsTextItem * text3=new QGraphicsTextItem();
text3->setHtml("200");
sc->addItem(text);
sc->addItem(text2);
sc->addItem(text3);
sc->addItem(line);
text->setPos(30, 0);
text2->setPos(30, 20);
text3->setPos(30, 45);
line->setPos(30, 40);
ui->graphicsView->setScene(sc);
ui->graphicsView->setAlignment(Qt::AlignTop|Qt::AlignLeft);
ui->graphicsView->update();
To copy to clipboard, switch view to plain text mode
Bookmarks