Obsolete Members for QGraphicsView

The following members of class QGraphicsView are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Public Functions

(obsolete) QMatrix matrix() const
(obsolete) void resetMatrix()
(obsolete) void setMatrix(const QMatrix &matrix, bool combine = false)

Protected Functions

(obsolete) virtual void drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem [] options)

Member Function Documentation

[virtual protected] void QGraphicsView::drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem [] options)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Draws the items items in the scene using painter, after the background and before the foreground are drawn. numItems is the number of items in items and options in options. options is a list of styleoptions; one for each item. Reimplement this function to provide custom item drawing for this view.

The default implementation calls the scene's drawItems() function.

Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.

See also drawForeground(), drawBackground(), and QGraphicsScene::drawItems().

QMatrix QGraphicsView::matrix() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use transform() instead.

Returns the current transformation matrix for the view. If no current transformation is set, the identity matrix is returned.

See also setMatrix(), transform(), rotate(), scale(), shear(), and translate().

void QGraphicsView::resetMatrix()

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use resetTransform() instead.

Resets the view transformation matrix to the identity matrix.

See also resetTransform().

void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine = false)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setTransform() instead.

Sets the view's current transformation matrix to matrix.

If combine is true, then matrix is combined with the current matrix; otherwise, matrix replaces the current matrix. combine is false by default.

The transformation matrix tranforms the scene into view coordinates. Using the default transformation, provided by the identity matrix, one pixel in the view represents one unit in the scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using 20x20 pixels in the view).

Example:

QGraphicsScene scene;
scene.addText("GraphicsView rotated clockwise");

QGraphicsView view(&scene);
view.rotate(90); // the text is rendered with a 90 degree clockwise rotation
view.show();

To simplify interation with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call mapToScene() to map a view coordinate to a floating point scene coordinate, or mapFromScene() to map from floating point scene coordinates to view coordinates.

See also matrix(), setTransform(), rotate(), scale(), shear(), and translate().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.