Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QGraphicsView::setScene ( QGraphicsScene scene  )  [inherited]

Sets the current scene to scene. If scene is already being viewed, this function does nothing.

When a scene is set on a view, the QGraphicsScene::changed() signal is automatically connected to this view's updateScene() slot, and the view's scroll bars are adjusted to fit the size of the scene.

Definition at line 1203 of file qgraphicsview.cpp.

References QRectF::center(), QObject::connect(), QObject::disconnect(), QGraphicsView::sceneRect, QWidget::update(), QGraphicsView::updateScene(), QGraphicsView::updateSceneRect(), and QAbstractScrollArea::viewport().

Referenced by MainWindow::MainWindow(), QGraphicsView::QGraphicsView(), and View().

{
    Q_D(QGraphicsView);
    if (d->scene == scene)
        return;

    // Always update the viewport when the scene changes.
    viewport()->update();

    // Remove the previously assigned scene.
    if (d->scene) {
        disconnect(d->scene, SIGNAL(changed(QList<QRectF>)),
                   this, SLOT(updateScene(QList<QRectF>)));
        disconnect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
                   this, SLOT(updateSceneRect(QRectF)));
        d->scene->d_func()->views.removeAll(this);
    }

    // Assign the new scene and update the contents (scrollbars, etc.)).
    if ((d->scene = scene)) {
        connect(d->scene, SIGNAL(changed(QList<QRectF>)),
                this, SLOT(updateScene(QList<QRectF>)));
        connect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
                this, SLOT(updateSceneRect(QRectF)));
        d->scene->d_func()->views << this;
        d->recalculateContentSize();
        d->lastCenterPoint = sceneRect().center();
        d->keepLastCenterPoint = true;
    } else {
        d->recalculateContentSize();
    }
}


Generated by  Doxygen 1.6.0   Back to index