C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ //-------------------Scene create--------------------------- scene = new QGraphicsScene((this)); scene->setSceneRect(QRectF(0, 0, 6400, 6400)); view = new QGraphicsView(scene); view->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); EllipseCraft = new QGraphicsEllipseItem(0,0,5,5); //------------------Drawing......----------------------------- ......................................}
C++ (Qt) PlaneViewer::PlaneViewer(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent){ m_scene = scene; gridKf = 256;}void PlaneViewer::paintEvent(QPaintEvent *event){ for(int i = 0; i < 6400; i+=gridKf) { QGraphicsLineItem *LineV = m_scene->addLine(i, 0, i, 6400); QGraphicsLineItem *LineH = m_scene->addLine(0, i, 6400, i); }}
C++ (Qt)void PlaneViewer::paintEvent(QPaintEvent *event){ for(int i = 0; i < 6400; i+=gridKf) { QGraphicsLineItem *LineV = m_scene->addLine(i, 0, i, 6400); QGraphicsLineItem *LineH = m_scene->addLine(0, i, 6400, i); }}
C++ (Qt)virtual void QGraphicsView::drawBackground ( QPainter * painter, const QRectF & rect )
C++ (Qt)virtual void QGraphicsView::drawForeground ( QPainter * painter, const QRectF & rect ){ for(int i = 0; i < scene()->width(); i+=gridKf) { painter->drawLine(i, 0, i, scene()->height()); painter->drawLine(0, i, scene()->width(), i); }}