Coordinate systems for QGrpahicsView/Scene and QPainter
-
Is there any difference?
In my QPainter code I just did a drawImage(x,y,*image).QGrpahicsView.
painter.setWindow(QRect(0, 0, canvasSizeX, canvasSizeY));
painter.setViewport(0, 0, canvasSizeX, canvasSizeY);QGraphicsPixmapItem *straightPixmapItem = scene->addPixmap(*image);
straightPixmapItem->setPos(x,y);But now when I do this, it never shows at the same location. Surely they should both output to the same location if the window size is the same?
-
try:
view->setAlignment(Qt::AlignLeft | Qt::AlignTop);Note: don't abuse dynamic memory, you don't need a QPixmap pointer:
void drawImage(qreal x, qreal y, const QPixmap & image){ QGraphicsPixmapItem *straightPixmapItem = scene->addPixmap(image); straightPixmapItem->setPos(x,y); }. -
@eyllanesc said in Coordinate systems for QGrpahicsView/Scene and QPainter:
view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
Thanks, it works, but what exactly is that command and what does it do?
-
@eyllanesc said in Coordinate systems for QGrpahicsView/Scene and QPainter:
view->setAlignment(Qt::AlignLeft | Qt::AlignTop);
Thanks, it works, but what exactly is that command and what does it do?
It tells how the view is "centered"