QT之二維繪圖:場景座標

場景座標的原點在場景中心code

QGraphicsScene scene;
    scene.addLine(QLineF(0, 0, 50, 0));
    scene.addLine(QLineF(0, 0, 0, 50));
    scene.addLine(QLineF(0, 0, -50, 0));
    scene.addLine(QLineF(0, 0, 0, -50));
    scene.addEllipse(QRectF(0, 0, 50, 50));
    scene.addRect(QRectF(0, 0, 25, 25));
    
    QGraphicsView view(&scene);  //必須將scene放到view中,不然不能看到圖形
    view.show();

相關文章
相關標籤/搜索