解释如何使用指针?

抱歉,我使用Google翻译器。 我正在探索QGraphicsItem的工作方式。 但是我不明白如何通过指向场景的指针传输数据。 这是一个代码

mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qmyscene.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    scene = new QMyScene(this);
    ui->graphicsView->setScene(scene);
    scene->setSceneRect(0,0,800,600);
    }

MainWindow::~MainWindow()
{
    delete ui;
}

qmyscene.cpp

#include "qmyscene.h"
#include "qpixitem.h"
#include <qdebug.h>
QMyScene::QMyScene(QObject *parent) : QGraphicsScene(parent)
{
    QPixItem *pix1 = new QPixItem (this,100,100);
    QPixItem *pix2 = new QPixItem (this,50,50);
}
QMyScene::~QMyScene()
{
}

qpixitem.cpp

#include "qpixitem.h"
#include <QMessageBox>
QPixItem::QPixItem (QGraphicsScene *MyScene,int x,int y): QGraphicsPixmapItem()
{
    QPixmap  pic (":/Items/OutLet.png");
    this->setPixmap(pic);
    this->setPos(x, y);
    this->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges);
    qDebug() << "create";
    QGraphicsLineItem* line = MyScene->addLine(QLineF(40, 40, 80, 80));
    MyScene->addItem(this);
}
QVariant QPixItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
    if (change == ItemPositionChange)
      {
        QPointF newPos = value.toPointF();
        int p1 = newPos.x();
        int p2 = newPos.y();
        MyScene->addLine(QLineF(40,40,p1, p2)); //error
        //this->line->setLine(QLineF(40,40,p1, p2)); //error
        qDebug() << "Scene::move";
       }
      return QGraphicsItem::itemChange(change, value);
}

//错误-这些行导致错误(由于访问内存而关闭程序),我确定这是由于指针使用不正确造成的。如何在这样的代码中正确使用它们?