是否可以在QGraphicsScene
的左上角设置(0,0)?默认情况下,它似乎位于视图的中心:
class GraphicsScene : public QGraphicsScene
{
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
{
// here you can see that (0,0) is at the center of the view
qDebug() << "movement " << event->scenePos();
}
};
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
GraphicsScene* scene = new GraphicsScene;
QGraphicsView* view = new QGraphicsView(scene);
setCentralWidget(view);
}
您必须在alignment
中设置alignment
:
QGraphicsView