![]() |
CopperSpice API
1.7.4
|
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene. More...
Public Types | |
enum | DragMode |
enum | ViewportAnchor |
enum | ViewportUpdateMode |
![]() | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
![]() | |
enum | RenderFlag |
![]() | |
enum | PaintDeviceMetric |
Public Signals | |
void | rubberBandChanged (QRect viewportRect, QPointF fromScenePoint, QPointF toScenePoint) |
![]() | |
void | customContextMenuRequested (const QPoint &pos) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | windowTitleChanged (const QString &title) |
![]() | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
void | invalidateScene (const QRectF &rect=QRectF (), QGraphicsScene::SceneLayers layers=QGraphicsScene::AllLayers) |
void | updateScene (const QList< QRectF > &rects) |
void | updateSceneRect (const QRectF &rect) |
![]() | |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | repaint () |
void | setDisabled (bool disable) |
void | setEnabled (bool enable) |
void | setFocus () |
void | setHidden (bool hidden) |
void | setStyleSheet (const QString &styleSheet) |
virtual void | setVisible (bool visible) |
void | setWindowModified (bool modified) |
void | setWindowTitle (const QString &title) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
void | update () |
![]() | |
void | deleteLater () |
Public Methods | |
QGraphicsView (QGraphicsScene *scene, QWidget *parent=nullptr) | |
QGraphicsView (QWidget *parent=nullptr) | |
~QGraphicsView () | |
Qt::Alignment | alignment () const |
QBrush | backgroundBrush () const |
CacheMode | cacheMode () const |
void | centerOn (const QGraphicsItem *item) |
void | centerOn (const QPointF &pos) |
void | centerOn (qreal x, qreal y) |
DragMode | dragMode () const |
void | ensureVisible (const QGraphicsItem *item, int xmargin=50, int ymargin=50) |
void | ensureVisible (const QRectF &rect, int xmargin=50, int ymargin=50) |
void | ensureVisible (qreal x, qreal y, qreal width, qreal height, int xmargin=50, int ymargin=50) |
void | fitInView (const QGraphicsItem *item, Qt::AspectRatioMode mode=Qt::IgnoreAspectRatio) |
void | fitInView (const QRectF &rect, Qt::AspectRatioMode mode=Qt::IgnoreAspectRatio) |
void | fitInView (qreal x, qreal y, qreal width, qreal height, Qt::AspectRatioMode mode=Qt::IgnoreAspectRatio) |
QBrush | foregroundBrush () const |
QVariant | inputMethodQuery (Qt::InputMethodQuery query) const override |
bool | isInteractive () const |
bool | isTransformed () const |
QGraphicsItem * | itemAt (const QPoint &pos) const |
QGraphicsItem * | itemAt (int x, int y) const |
QList< QGraphicsItem * > | items () const |
QList< QGraphicsItem * > | items (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
QList< QGraphicsItem * > | items (const QPoint &pos) const |
QList< QGraphicsItem * > | items (const QPolygon &polygon, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
QList< QGraphicsItem * > | items (const QRect &rect, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
QList< QGraphicsItem * > | items (int x, int y) const |
QList< QGraphicsItem * > | items (int x, int y, int width, int height, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
QPainterPath | mapFromScene (const QPainterPath &path) const |
QPoint | mapFromScene (const QPointF &point) const |
QPolygon | mapFromScene (const QPolygonF &polygon) const |
QPolygon | mapFromScene (const QRectF &rect) const |
QPoint | mapFromScene (qreal x, qreal y) const |
QPolygon | mapFromScene (qreal x, qreal y, qreal width, qreal height) const |
QPainterPath | mapToScene (const QPainterPath &path) const |
QPointF | mapToScene (const QPoint &point) const |
QPolygonF | mapToScene (const QPolygon &polygon) const |
QPolygonF | mapToScene (const QRect &rect) const |
QPointF | mapToScene (int x, int y) const |
QPolygonF | mapToScene (int x, int y, int width, int height) const |
QMatrix | matrix () const |
OptimizationFlags | optimizationFlags () const |
void | render (QPainter *painter, const QRectF &target=QRectF (), const QRect &source=QRect (), Qt::AspectRatioMode mode=Qt::KeepAspectRatio) |
QPainter::RenderHints | renderHints () const |
void | resetCachedContent () |
void | resetMatrix () |
void | resetTransform () |
ViewportAnchor | resizeAnchor () const |
void | rotate (qreal angle) |
QRect | rubberBandRect () const |
Qt::ItemSelectionMode | rubberBandSelectionMode () const |
void | scale (qreal sx, qreal sy) |
QGraphicsScene * | scene () const |
QRectF | sceneRect () const |
void | setAlignment (Qt::Alignment alignment) |
void | setBackgroundBrush (const QBrush &brush) |
void | setCacheMode (CacheMode mode) |
void | setDragMode (DragMode mode) |
void | setForegroundBrush (const QBrush &brush) |
void | setInteractive (bool allowed) |
void | setMatrix (const QMatrix &matrix, bool combine=false) |
void | setOptimizationFlag (OptimizationFlag flag, bool enabled=true) |
void | setOptimizationFlags (OptimizationFlags flags) |
void | setRenderHint (QPainter::RenderHint hint, bool enabled=true) |
void | setRenderHints (QPainter::RenderHints hints) |
void | setResizeAnchor (ViewportAnchor anchor) |
void | setRubberBandSelectionMode (Qt::ItemSelectionMode mode) |
void | setScene (QGraphicsScene *scene) |
void | setSceneRect (const QRectF &rect) |
void | setSceneRect (qreal x, qreal y, qreal width, qreal height) |
void | setTransform (const QTransform &matrix, bool combine=false) |
void | setTransformationAnchor (ViewportAnchor anchor) |
void | setViewportUpdateMode (ViewportUpdateMode mode) |
void | shear (qreal sh, qreal sv) |
QSize | sizeHint () const override |
QTransform | transform () const |
ViewportAnchor | transformationAnchor () const |
void | translate (qreal dx, qreal dy) |
QTransform | viewportTransform () const |
ViewportUpdateMode | viewportUpdateMode () const |
![]() | |
QAbstractScrollArea (QWidget *parent=nullptr) | |
~QAbstractScrollArea () | |
void | addScrollBarWidget (QWidget *widget, Qt::Alignment alignment) |
QWidget * | cornerWidget () const |
QScrollBar * | horizontalScrollBar () const |
Qt::ScrollBarPolicy | horizontalScrollBarPolicy () const |
QSize | maximumViewportSize () const |
QSize | minimumSizeHint () const override |
QWidgetList | scrollBarWidgets (Qt::Alignment alignment) |
void | setCornerWidget (QWidget *widget) |
void | setHorizontalScrollBar (QScrollBar *scrollBar) |
void | setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy) |
void | setSizeAdjustPolicy (SizeAdjustPolicy policy) |
virtual void | setupViewport (QWidget *viewport) |
void | setVerticalScrollBar (QScrollBar *scrollBar) |
void | setVerticalScrollBarPolicy (Qt::ScrollBarPolicy) |
void | setViewport (QWidget *widget) |
SizeAdjustPolicy | sizeAdjustPolicy () const |
QSize | sizeHint () const override |
QScrollBar * | verticalScrollBar () const |
Qt::ScrollBarPolicy | verticalScrollBarPolicy () const |
QWidget * | viewport () const |
![]() | |
QFrame (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QFrame () | |
QRect | frameRect () const |
Shadow | frameShadow () const |
Shape | frameShape () const |
int | frameStyle () const |
int | frameWidth () const |
int | lineWidth () const |
int | midLineWidth () const |
void | setFrameRect (const QRect &rect) |
void | setFrameShadow (Shadow value) |
void | setFrameShape (Shape value) |
void | setFrameStyle (int style) |
void | setLineWidth (int width) |
void | setMidLineWidth (int width) |
QSize | sizeHint () const override |
![]() | |
QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) | |
~QWidget () | |
bool | acceptDrops () const |
QString | accessibleDescription () const |
QString | accessibleName () const |
QList< QAction * > | actions () const |
void | activateWindow () |
void | addAction (QAction *action) |
void | addActions (const QList< QAction * > &actions) |
void | adjustSize () |
bool | autoFillBackground () const |
QPalette::ColorRole | backgroundRole () const |
QBackingStore * | backingStore () const |
QSize | baseSize () const |
QWidget * | childAt (const QPoint &position) const |
QWidget * | childAt (int x, int y) const |
QRect | childrenRect () const |
QRegion | childrenRegion () const |
void | clearFocus () |
void | clearMask () |
QMargins | contentsMargins () const |
QRect | contentsRect () const |
Qt::ContextMenuPolicy | contextMenuPolicy () const |
QCursor | cursor () const |
WId | effectiveWinId () const |
void | ensurePolished () const |
Qt::FocusPolicy | focusPolicy () const |
QWidget * | focusProxy () const |
QWidget * | focusWidget () const |
const QFont & | font () const |
QFontInfo | fontInfo () const |
QFontMetrics | fontMetrics () const |
QPalette::ColorRole | foregroundRole () const |
QRect | frameGeometry () const |
QSize | frameSize () const |
const QRect & | geometry () const |
void | getContentsMargins (int *left, int *top, int *right, int *bottom) const |
QPixmap | grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1))) |
void | grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ()) |
void | grabKeyboard () |
void | grabMouse () |
void | grabMouse (const QCursor &cursor) |
int | grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut) |
QGraphicsEffect * | graphicsEffect () const |
QGraphicsProxyWidget * | graphicsProxyWidget () const |
bool | hasEditFocus () const |
bool | hasFocus () const |
virtual bool | hasHeightForWidth () const |
bool | hasMouseTracking () const |
int | height () const |
virtual int | heightForWidth (int width) const |
Qt::InputMethodHints | inputMethodHints () const |
void | insertAction (QAction *before, QAction *action) |
void | insertActions (QAction *before, QList< QAction * > actions) |
bool | isActiveWindow () const |
bool | isAncestorOf (const QWidget *child) const |
bool | isEnabled () const |
bool | isEnabledTo (const QWidget *parent) const |
bool | isEnabledToTLW () const |
bool | isFullScreen () const |
bool | isHidden () const |
bool | isMaximized () const |
bool | isMinimized () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
bool | isVisibleTo (const QWidget *parent) const |
bool | isWindow () const |
bool | isWindowModified () const |
QLayout * | layout () const |
Qt::LayoutDirection | layoutDirection () const |
QLocale | locale () const |
QPoint | mapFrom (const QWidget *parent, const QPoint &pos) const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapFromParent (const QPoint &pos) const |
QPoint | mapTo (const QWidget *parent, const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QPoint | mapToParent (const QPoint &pos) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
void | move (const QPoint &point) |
void | move (int x, int y) |
QWidget * | nativeParentWidget () const |
QWidget * | nextInFocusChain () const |
QRect | normalGeometry () const |
void | overrideWindowFlags (Qt::WindowFlags flags) |
QPaintEngine * | paintEngine () const override |
const QPalette & | palette () const |
QWidget * | parentWidget () const |
QPoint | pos () const |
QWidget * | previousInFocusChain () const |
QRect | rect () const |
void | releaseKeyboard () |
void | releaseMouse () |
void | releaseShortcut (int id) |
void | removeAction (QAction *action) |
void | render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren)) |
void | repaint (const QRect &rect) |
void | repaint (const QRegion ®ion) |
void | repaint (int x, int y, int w, int h) |
void | resize (const QSize &size) |
void | resize (int w, int h) |
bool | restoreGeometry (const QByteArray &geometry) |
QByteArray | saveGeometry () const |
void | scroll (int dx, int dy) |
void | scroll (int dx, int dy, const QRect &rect) |
void | setAcceptDrops (bool on) |
void | setAccessibleDescription (const QString &description) |
void | setAccessibleName (const QString &name) |
void | setAttribute (Qt::WidgetAttribute attribute, bool enable=true) |
void | setAutoFillBackground (bool enable) |
void | setBackgroundRole (QPalette::ColorRole role) |
void | setBaseSize (const QSize &size) |
void | setBaseSize (int basew, int baseh) |
void | setContentsMargins (const QMargins &margins) |
void | setContentsMargins (int left, int top, int right, int bottom) |
void | setContextMenuPolicy (Qt::ContextMenuPolicy policy) |
void | setCursor (const QCursor &cursor) |
void | setEditFocus (bool enable) |
void | setFixedHeight (int h) |
void | setFixedSize (const QSize &size) |
void | setFixedSize (int w, int h) |
void | setFixedWidth (int w) |
void | setFocus (Qt::FocusReason reason) |
void | setFocusPolicy (Qt::FocusPolicy policy) |
void | setFocusProxy (QWidget *widget) |
void | setFont (const QFont &font) |
void | setForegroundRole (QPalette::ColorRole role) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int x, int y, int w, int h) |
void | setGraphicsEffect (QGraphicsEffect *effect) |
void | setInputMethodHints (Qt::InputMethodHints hints) |
void | setLayout (QLayout *layout) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setLocale (const QLocale &locale) |
void | setMask (const QBitmap &bitmap) |
void | setMask (const QRegion ®ion) |
void | setMaximumHeight (int maxh) |
void | setMaximumSize (const QSize &size) |
void | setMaximumSize (int maxw, int maxh) |
void | setMaximumWidth (int maxw) |
void | setMinimumHeight (int minh) |
void | setMinimumSize (const QSize &size) |
void | setMinimumSize (int minw, int minh) |
void | setMinimumWidth (int minw) |
void | setMouseTracking (bool enable) |
void | setPalette (const QPalette &palette) |
void | setParent (QWidget *parent) |
void | setParent (QWidget *parent, Qt::WindowFlags flags) |
void | setShortcutAutoRepeat (int id, bool enable=true) |
void | setShortcutEnabled (int id, bool enable=true) |
void | setSizeIncrement (const QSize &size) |
void | setSizeIncrement (int w, int h) |
void | setSizePolicy (QSizePolicy policy) |
void | setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical) |
void | setStatusTip (const QString &data) |
void | setStyle (QStyle *style) |
void | setToolTip (const QString &data) |
void | setToolTipDuration (int msec) |
void | setUpdatesEnabled (bool enable) |
void | setWhatsThis (const QString &str) |
void | setWindowFilePath (const QString &filePath) |
void | setWindowFlags (Qt::WindowFlags flags) |
void | setWindowIcon (const QIcon &icon) |
void | setWindowModality (Qt::WindowModality windowModality) |
void | setWindowOpacity (qreal level) |
void | setWindowRole (const QString &role) |
void | setWindowState (Qt::WindowStates windowState) |
QSize | size () const |
QSize | sizeIncrement () const |
QSizePolicy | sizePolicy () const |
void | stackUnder (QWidget *widget) |
QString | statusTip () const |
QStyle * | style () const |
QString | styleSheet () const |
bool | testAttribute (Qt::WidgetAttribute attribute) const |
QString | toolTip () const |
int | toolTipDuration () const |
QWidget * | topLevelWidget () const |
bool | underMouse () const |
void | ungrabGesture (Qt::GestureType gestureType) |
void | unsetCursor () |
void | unsetLayoutDirection () |
void | unsetLocale () |
void | update (const QRect &rect) |
void | update (const QRegion ®ion) |
void | update (int x, int y, int w, int h) |
void | updateGeometry () |
bool | updatesEnabled () const |
QRegion | visibleRegion () const |
QString | whatsThis () const |
int | width () const |
QWidget * | window () const |
QString | windowFilePath () const |
Qt::WindowFlags | windowFlags () const |
QWindow * | windowHandle () const |
QIcon | windowIcon () const |
Qt::WindowModality | windowModality () const |
qreal | windowOpacity () const |
QString | windowRole () const |
Qt::WindowStates | windowState () const |
QString | windowTitle () const |
Qt::WindowType | windowType () const |
WId | winId () const |
int | x () const |
int | y () const |
![]() | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
![]() | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Protected Slots | |
void | setupViewport (QWidget *widget) |
![]() | |
void | updateMicroFocus () |
Protected Methods | |
void | contextMenuEvent (QContextMenuEvent *event) override |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dragMoveEvent (QDragMoveEvent *event) override |
virtual void | drawBackground (QPainter *painter, const QRectF &rect) |
virtual void | drawForeground (QPainter *painter, const QRectF &rect) |
virtual void | drawItems (QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[]) |
void | dropEvent (QDropEvent *event) override |
bool | event (QEvent *event) override |
void | focusInEvent (QFocusEvent *event) override |
bool | focusNextPrevChild (bool next) override |
void | focusOutEvent (QFocusEvent *event) override |
void | inputMethodEvent (QInputMethodEvent *event) override |
void | keyPressEvent (QKeyEvent *event) override |
void | keyReleaseEvent (QKeyEvent *event) override |
void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | paintEvent (QPaintEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
void | scrollContentsBy (int dx, int dy) override |
void | showEvent (QShowEvent *event) override |
bool | viewportEvent (QEvent *event) override |
void | wheelEvent (QWheelEvent *event) override |
![]() | |
void | contextMenuEvent (QContextMenuEvent *event) override |
void | dragEnterEvent (QDragEnterEvent *event) override |
void | dragLeaveEvent (QDragLeaveEvent *event) override |
void | dragMoveEvent (QDragMoveEvent *event) override |
void | dropEvent (QDropEvent *event) override |
bool | event (QEvent *event) override |
void | keyPressEvent (QKeyEvent *event) override |
void | mouseDoubleClickEvent (QMouseEvent *event) override |
void | mouseMoveEvent (QMouseEvent *event) override |
void | mousePressEvent (QMouseEvent *event) override |
void | mouseReleaseEvent (QMouseEvent *event) override |
void | paintEvent (QPaintEvent *event) override |
void | resizeEvent (QResizeEvent *event) override |
void | setViewportMargins (const QMargins &margins) |
void | setViewportMargins (int left, int top, int right, int bottom) |
QMargins | viewportMargins () const |
virtual QSize | viewportSizeHint () const |
void | wheelEvent (QWheelEvent *event) override |
![]() | |
void | changeEvent (QEvent *event) override |
void | drawFrame (QPainter *painter) |
bool | event (QEvent *event) override |
void | initStyleOption (QStyleOptionFrame *option) const |
void | paintEvent (QPaintEvent *event) override |
![]() | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true) |
void | destroy (bool destroyWindow=true, bool destroySubWindows=true) |
virtual void | enterEvent (QEvent *event) |
bool | event (QEvent *event) override |
bool | focusNextChild () |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
void | initPainter (QPainter *painter) const override |
virtual void | leaveEvent (QEvent *event) |
int | metric (PaintDeviceMetric metric) const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | tabletEvent (QTabletEvent *event) |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
![]() | |
QPaintDevice () | |
Friends | |
class | QGraphicsScene |
Additional Inherited Members | |
![]() | |
static QWidget * | createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag) |
static QWidget * | find (WId id) |
static QWidget * | keyboardGrabber () |
static QWidget * | mouseGrabber () |
static void | setTabOrder (QWidget *firstWidget, QWidget *secondWidget) |
![]() | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
![]() | |
QWidgetList | |
WId | |
![]() | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene. This class visualizes the contents of a QGraphicsScene in a scrollable viewport. To create a scene with geometrical items, refer to the QGraphicsScene documentation. QGraphicsView is part of the Graphics View System.
To visualize a scene, you start by constructing a QGraphicsView object, passing the address of the scene you want to visualize to QGraphicsView's constructor. Alternatively, you can call setScene() to set the scene at a later point. After you call show(), the view will by default scroll to the center of the scene and display any items that are visible at this point.
You can explicitly scroll to any position on the scene by using the scroll bars, or by calling centerOn(). By passing a point to centerOn(), QGraphicsView will scroll its viewport to ensure that the point is centered in the view. An overload is provided for scrolling to a QGraphicsItem, in which case QGraphicsView will see to that the center of the item is centered in the view. If all you want is to ensure that a certain area is visible, (but not necessarily centered,) you can call ensureVisible() instead.
QGraphicsView can be used to visualize a whole scene, or only parts of it. The visualized area is by default detected automatically when the view is displayed for the first time (by calling QGraphicsScene::itemsBoundingRect()). To set the visualized area rectangle yourself, you can call setSceneRect(). This will adjust the scroll bars' ranges appropriately. Note that although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX).
QGraphicsView visualizes the scene by calling render(). By default, the items are drawn onto the viewport by using a regular QPainter, and using default render hints. To change the default render hints that QGraphicsView passes to QPainter when painting items, you can call setRenderHints().
By default, QGraphicsView provides a regular QWidget for the viewport widget. You can access this widget by calling viewport(), or you can replace it by calling setViewport(). To render using OpenGL, simply call setViewport(new QGLWidget). QGraphicsView takes ownership of the viewport widget.
QGraphicsView supports affine transformations, using QTransform. You can either pass a matrix to setTransform(), or you can call one of the convenience functions rotate(), scale(), translate() or shear(). The most two common transformations are scaling, which is used to implement zooming, and rotation. QGraphicsView keeps the center of the view fixed during a transformation. Because of the scene alignment (setAlignment()), translating the view will have no visual impact.
You can interact with the items on the scene by using the mouse and keyboard. QGraphicsView translates the mouse and key events into scene events, (events that inherit QGraphicsSceneEvent,), and forward them to the visualized scene. In the end, it's the individual item that handles the events and reacts to them. For example, if you click on a selectable item, the item will typically let the scene know that it has been selected, and it will also redraw itself to display a selection rectangle. If you click and drag the mouse to move a movable item, it's the item that handles the mouse moves and moves itself. Item interaction is enabled by default, and you can toggle it by calling setInteractive().
You can also provide your own custom scene interaction, by creating a subclass of QGraphicsView, and reimplementing the mouse and key event handlers. To simplify how you programmatically interact with items in the view, QGraphicsView provides the mapping functions mapToScene() and mapFromScene(), and the item accessors items() and itemAt(). These functions allow you to map points, rectangles, polygons and paths between view coordinates and scene coordinates, and to find items on the scene using view coordinates.
This enum describes the default action for the view when pressing and dragging the mouse over the viewport.
Constant | Value | Description |
---|---|---|
QGraphicsView::NoDrag | 0 | Nothing happens; the mouse event is ignored. |
QGraphicsView::ScrollHandDrag | 1 | The cursor changes into a pointing hand, and dragging the mouse around will scroll the scrollbars. This mode works both in interactive and non-interactive mode. |
QGraphicsView::RubberBandDrag | 2 | A rubber band will appear. Dragging the mouse will set the rubber band geometry, and all items covered by the rubber band are selected. This mode is disabled for non-interactive views. |
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or when the view is transformed.
Constant | Value | Description |
---|---|---|
QGraphicsView::NoAnchor | 0 | No anchor, i.e. the view leaves the scene's position unchanged. |
QGraphicsView::AnchorViewCenter | 1 | The scene point at the center of the view is used as the anchor. |
QGraphicsView::AnchorUnderMouse | 2 | The point under the mouse is used as the anchor. |
This enum describes how QGraphicsView updates its viewport when the scene contents change or are exposed.
Constant | Value | Description |
---|---|---|
QGraphicsView::FullViewportUpdate | 0 | When any visible part of the scene changes or is reexposed, QGraphicsView will update the entire viewport. This approach is fastest when QGraphicsView spends more time figuring out what to draw than it would spend drawing (e.g., when very many small items are repeatedly updated). This is the preferred update mode for viewports that do not support partial updates, such as QGLWidget, and for viewports that need to disable scroll optimization. |
QGraphicsView::MinimalViewportUpdate | 1 | QGraphicsView will determine the minimal viewport region that requires a redraw, minimizing the time spent drawing by avoiding a redraw of areas that have not changed. This is QGraphicsView's default mode. Although this approach provides the best performance in general, if there are many small visible changes on the scene, QGraphicsView might end up spending more time finding the minimal approach than it will spend drawing. |
QGraphicsView::SmartViewportUpdate | 2 | QGraphicsView will attempt to find an optimal update mode by analyzing the areas that require a redraw. |
QGraphicsView::BoundingRectViewportUpdate | 4 | The bounding rectangle of all changes in the viewport will be redrawn. This mode has the advantage that QGraphicsView searches only one region for changes, minimizing time spent determining what needs redrawing. The disadvantage is that areas that have not changed also need to be redrawn. |
QGraphicsView::NoViewportUpdate | 3 | QGraphicsView will never update its viewport when the scene changes; the user is expected to control all updates. This mode disables all (potentially slow) item visibility testing in QGraphicsView, and is suitable for scenes that either require a fixed frame rate, or where the viewport is otherwise updated externally. |
QGraphicsView::QGraphicsView | ( | QWidget * | parent = nullptr | ) |
Constructs a QGraphicsView. The parent is passed to QWidget's constructor.
QGraphicsView::QGraphicsView | ( | QGraphicsScene * | scene, |
QWidget * | parent = nullptr |
||
) |
Constructs a QGraphicsView and sets the visualized scene to scene. The parent is passed to QWidget's constructor.
QGraphicsView::~QGraphicsView | ( | ) |
Destructs the QGraphicsView object.
Qt::Alignment QGraphicsView::alignment | ( | ) | const |
Property documentation pending.
QBrush QGraphicsView::backgroundBrush | ( | ) | const |
Property documentation pending.
CacheMode QGraphicsView::cacheMode | ( | ) | const |
Property documentation pending.
void QGraphicsView::centerOn | ( | const QGraphicsItem * | item | ) |
Scrolls the contents of the viewport to ensure that item is centered in the view.
void QGraphicsView::centerOn | ( | const QPointF & | pos | ) |
Scrolls the contents of the viewport to ensure that the scene coordinate pos, is centered in the view. Because pos is a floating point coordinate, and the scroll bars operate on integer coordinates, the centering is only an approximation.
|
overrideprotectedvirtual |
Reimplemented from QWidget::contextMenuEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragEnterEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragLeaveEvent().
Reimplemented from QWidget.
DragMode QGraphicsView::dragMode | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QWidget::dragMoveEvent().
Reimplemented from QWidget.
Draws the background of the scene using painter, before any items and the foreground are drawn. Reimplement this function to provide a custom background for this view.
If all you want is to define a color, texture or gradient for the background, you can call setBackgroundBrush() instead.
All painting is done in scene coordinates. rect is the exposed rectangle.
The default implementation fills rect using the view's backgroundBrush. If no such brush is defined (the default), the scene's drawBackground() function is called instead.
Draws the foreground of the scene using painter, after the background and all items are drawn. Reimplement this function to provide a custom foreground for this view.
If all you want is to define a color, texture or gradient for the foreground, you can call setForegroundBrush() instead.
All painting is done in scene coordinates. rect is the exposed rectangle.
The default implementation fills rect using the view's foregroundBrush. If no such brush is defined (the default), the scene's drawForeground() function is called instead.
|
deprecatedprotectedvirtual |
The default implementation calls the scene's drawItems() function.
This function is not called unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.
|
overrideprotectedvirtual |
Reimplemented from QWidget::dropEvent().
Reimplemented from QWidget.
void QGraphicsView::ensureVisible | ( | const QGraphicsItem * | item, |
int | xmargin = 50 , |
||
int | ymargin = 50 |
||
) |
Scrolls the contents of the viewport so the center of item is visible, with margins specified in pixels by xmargin and ymargin. If the specified point can not be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.
void QGraphicsView::ensureVisible | ( | const QRectF & | rect, |
int | xmargin = 50 , |
||
int | ymargin = 50 |
||
) |
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specified in pixels by xmargin and ymargin. If the specified rect can not be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.
|
inline |
This method is provided for convenience. It is equivalent to calling ensureVisible(QRectF(x, y, w, h), xmargin, ymargin).
|
overrideprotected |
Reimplemented from QObject::event().
void QGraphicsView::fitInView | ( | const QGraphicsItem * | item, |
Qt::AspectRatioMode | mode = Qt::IgnoreAspectRatio |
||
) |
Ensures item fits tightly inside the view, scaling the view according to mode.
void QGraphicsView::fitInView | ( | const QRectF & | rect, |
Qt::AspectRatioMode | mode = Qt::IgnoreAspectRatio |
||
) |
Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits inside the viewport. The rect must be inside the scene rect, otherwise fitInView() can not guarantee that the whole rect is visible.
This function keeps the view's rotation, translation, or shear. The view is scaled according to mode. The rect will be centered in the view if it does not fit tightly.
It's common to call fitInView() from inside a reimplementation of resizeEvent(), to ensure that the whole scene, or parts of the scene, scales automatically to fit the new size of the viewport as the view is resized. Note though, that calling fitInView() from inside resizeEvent() can lead to unwanted resize recursion, if the new transformation toggles the automatic state of the scrollbars. You can toggle the scrollbar policies to always on or always off to prevent this (see horizontalScrollBarPolicy() and verticalScrollBarPolicy()).
If rect is empty, or if the viewport is too small, this function will do nothing.
|
inline |
Equivalent to calling fitInView(QRectF(x, y, w, h), mode).
|
overrideprotectedvirtual |
Reimplemented from QWidget::focusInEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::focusNextPrevChild().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::focusOutEvent().
Reimplemented from QWidget.
QBrush QGraphicsView::foregroundBrush | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QWidget::inputMethodEvent().
Reimplemented from QWidget.
|
overridevirtual |
Reimplemented from QWidget::inputMethodQuery().
Reimplemented from QWidget.
|
slot |
Invalidates and schedules a redraw of layers inside rect. The rect is in scene coordinates. Any cached content for layers inside rect is unconditionally invalidated and redrawn.
You can call this function to notify QGraphicsView of changes to the background or the foreground of the scene. It is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled background caching.
QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but QGraphicsScene::BackgroundLayer is passed.
bool QGraphicsView::isInteractive | ( | ) | const |
Property documentation pending.
bool QGraphicsView::isTransformed | ( | ) | const |
Returns true if the view is transformed (i.e., a non-identity transform has been assigned, or the scrollbars are adjusted).
QGraphicsItem * QGraphicsView::itemAt | ( | const QPoint & | pos | ) | const |
Returns the item at position pos, which is in viewport coordinates. If there are several items at this position, this function returns the topmost item.
|
inline |
QList< QGraphicsItem * > QGraphicsView::items | ( | ) | const |
Returns a list of all the items in the associated scene, in descending stacking order (i.e., the first item in the returned list is the uppermost item).
QList< QGraphicsItem * > QGraphicsView::items | ( | const QPainterPath & | path, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
Returns a list of all the items that, depending on mode, are either contained by or intersect with path. The value for path is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by path are returned.
QList< QGraphicsItem * > QGraphicsView::items | ( | const QPoint & | pos | ) | const |
Returns a list of all the items at the position pos in the view. The items are listed in descending stacking order (i.e., the first item in the list is the uppermost item, and the last item is the lowermost item). pos is in viewport coordinates.
This function is most commonly called from within mouse event handlers in a subclass in QGraphicsView. pos is in untransformed viewport coordinates, just like QMouseEvent::pos().
QList< QGraphicsItem * > QGraphicsView::items | ( | const QPolygon & | polygon, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
Returns a list of all the items that, depending on mode, are either contained by or intersect with polygon. The value for polygon is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by polygon are returned. The items are sorted by descending stacking order (i.e., the first item in the returned list is the uppermost item).
QList< QGraphicsItem * > QGraphicsView::items | ( | const QRect & | rect, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
Returns a list of all the items that, depending on mode, are either contained by or intersect with rect. The value for rect is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by rect are returned. The items are sorted in descending stacking order (i.e., the first item in the returned list is the uppermost item).
|
inline |
This function is provided for convenience. It's equivalent to calling items(QPoint(x, y)).
|
inline |
This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).
|
overrideprotectedvirtual |
Reimplemented from QWidget::keyPressEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::keyReleaseEvent().
Reimplemented from QWidget.
QPainterPath QGraphicsView::mapFromScene | ( | const QPainterPath & | path | ) | const |
Returns the scene coordinate painter path path to a viewport coordinate painter path.
Returns the scene coordinate point to viewport coordinates.
Returns the scene coordinate polygon polygon to a viewport coordinate polygon.
Returns the scene rectangle rect to a viewport coordinate polygon.
This function is provided for convenience. It's equivalent to calling mapFromScene(QPointF(x, y)).
This function is provided for convenience. It's equivalent to calling mapFromScene(QRectF(x, y, w, h)).
QPainterPath QGraphicsView::mapToScene | ( | const QPainterPath & | path | ) | const |
Returns the viewport painter path path mapped to a scene coordinate painter path.
Returns the viewport coordinate point mapped to scene coordinates.
Note: It can be useful to map the whole rectangle covered by the pixel at point instead of the point itself. To do this, you can call mapToScene(QRect(point, QSize(2, 2))).
Returns the viewport polygon polygon mapped to a scene coordinate polygon.
Returns the viewport rectangle rect mapped to a scene coordinate polygon.
|
inline |
This function is provided for convenience. It's equivalent to calling mapToScene(QPoint(x, y)).
|
inline |
This function is provided for convenience. It's equivalent to calling mapToScene(QRect(x, y, w, h)).
QMatrix QGraphicsView::matrix | ( | ) | const |
Returns the current transformation matrix for the view. If no current transformation is set, the identity matrix is returned.
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseDoubleClickEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseMoveEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::mousePressEvent().
Reimplemented from QWidget.
|
overrideprotectedvirtual |
Reimplemented from QWidget::mouseReleaseEvent().
Reimplemented from QWidget.
OptimizationFlags QGraphicsView::optimizationFlags | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QWidget::paintEvent().
Reimplemented from QWidget.
void QGraphicsView::render | ( | QPainter * | painter, |
const QRectF & | target = QRectF() , |
||
const QRect & | source = QRect() , |
||
Qt::AspectRatioMode | mode = Qt::KeepAspectRatio |
||
) |
Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. This function is useful for capturing the contents of the view onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing to QPrinter.
If source is a null rect, this function will use viewport()->rect() to determine what to draw. If target is a null rect, the full dimensions of painter's paint device (e.g., for a QPrinter, the page size) will be used.
The source rect contents will be transformed according to mode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
QPainter::RenderHints QGraphicsView::renderHints | ( | ) | const |
Property documentation pending.
void QGraphicsView::resetCachedContent | ( | ) |
Resets any cached content. Calling this function will clear QGraphicsView's cache. If the current cache mode is CacheNone, this function does nothing.
This function is called automatically for you when the backgroundBrush or QGraphicsScene::backgroundBrush properties change; you only need to call this function if you have reimplemented QGraphicsScene::drawBackground() or QGraphicsView::drawBackground() to draw a custom background, and need to trigger a full redraw.
void QGraphicsView::resetMatrix | ( | ) |
Resets the view transformation matrix to the identity matrix.
void QGraphicsView::resetTransform | ( | ) |
Resets the view transformation to the identity matrix.
ViewportAnchor QGraphicsView::resizeAnchor | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QWidget::resizeEvent().
Reimplemented from QWidget.
void QGraphicsView::rotate | ( | qreal | angle | ) |
Rotates the current view transformation angle degrees clockwise.
|
signal |
This signal is emitted when the rubber band rect is changed. The viewport Rect is specified by rubberBandRect. The drag start position and drag end position are provided in scene points with fromScenePoint and toScenePoint.
When rubberband selection ends this signal will be emitted with null vales.
QRect QGraphicsView::rubberBandRect | ( | ) | const |
This method returns the current rubber band area (in viewport coordinates) if the user is currently doing an item selection with the rubber band. When the user is not using the rubber band this method returns a null QRectF.
Part of this QRect can be outside the visual viewport or contain negative values.
Qt::ItemSelectionMode QGraphicsView::rubberBandSelectionMode | ( | ) | const |
Property documentation pending.
Scales the current view transformation by (sx, sy).
QGraphicsScene * QGraphicsView::scene | ( | ) | const |
Returns a pointer to the scene that is currently visualized in the view. If no scene is currently visualized, 0 is returned.
QRectF QGraphicsView::sceneRect | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QAbstractScrollArea::scrollContentsBy().
Reimplemented from QAbstractScrollArea.
void QGraphicsView::setAlignment | ( | Qt::Alignment | alignment | ) |
Property documentation pending.
void QGraphicsView::setBackgroundBrush | ( | const QBrush & | brush | ) |
Property documentation pending.
void QGraphicsView::setCacheMode | ( | CacheMode | mode | ) |
Property documentation pending.
void QGraphicsView::setDragMode | ( | DragMode | mode | ) |
Property documentation pending.
void QGraphicsView::setForegroundBrush | ( | const QBrush & | brush | ) |
Property documentation pending.
void QGraphicsView::setInteractive | ( | bool | allowed | ) |
Property documentation pending.
void QGraphicsView::setMatrix | ( | const QMatrix & | matrix, |
bool | combine = false |
||
) |
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 transforms 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).
To simplify interaction 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.
void QGraphicsView::setOptimizationFlag | ( | OptimizationFlag | flag, |
bool | enabled = true |
||
) |
Enables flag if enabled is true, otherwise disables flag.
void QGraphicsView::setOptimizationFlags | ( | OptimizationFlags | flags | ) |
Property documentation pending.
void QGraphicsView::setRenderHint | ( | QPainter::RenderHint | hint, |
bool | enabled = true |
||
) |
If enabled is true, the render hint hint is enabled, otherwise it is disabled.
void QGraphicsView::setRenderHints | ( | QPainter::RenderHints | hints | ) |
Property documentation pending.
void QGraphicsView::setResizeAnchor | ( | ViewportAnchor | anchor | ) |
Property documentation pending.
void QGraphicsView::setRubberBandSelectionMode | ( | Qt::ItemSelectionMode | mode | ) |
Property documentation pending.
void QGraphicsView::setScene | ( | QGraphicsScene * | scene | ) |
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.
void QGraphicsView::setSceneRect | ( | const QRectF & | rect | ) |
Property documentation pending.
Property documentation pending.
void QGraphicsView::setTransform | ( | const QTransform & | matrix, |
bool | combine = false |
||
) |
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 transforms 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).
To simplify interaction 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.
void QGraphicsView::setTransformationAnchor | ( | ViewportAnchor | anchor | ) |
Property documentation pending.
|
protectedslot |
This slot is called by QAbstractScrollArea after setViewport() has been called. Reimplement this function in a subclass of QGraphicsView to initialize the new viewport widget before it is used.
void QGraphicsView::setViewportUpdateMode | ( | ViewportUpdateMode | mode | ) |
Property documentation pending.
Shears the current view transformation by (sh, sv).
|
overrideprotectedvirtual |
Reimplemented from QWidget::showEvent().
Reimplemented from QWidget.
|
overridevirtual |
Reimplemented from QWidget::sizeHint().
Reimplemented from QWidget.
QTransform QGraphicsView::transform | ( | ) | const |
Returns the current transformation matrix for the view. If no current transformation is set, the identity matrix is returned.
ViewportAnchor QGraphicsView::transformationAnchor | ( | ) | const |
Property documentation pending.
Translates the current view transformation by (dx, dy).
Schedules an update of the scene rectangles rects.
|
slot |
Notifies QGraphicsView that the scene's scene rect has changed. rect is the new scene rect. If the view already has an explicitly set scene rect, this function does nothing.
|
overrideprotectedvirtual |
Reimplemented from QAbstractScrollArea::viewportEvent().
Reimplemented from QAbstractScrollArea.
QTransform QGraphicsView::viewportTransform | ( | ) | const |
Returns a matrix that maps viewport coordinates to scene coordinates.
ViewportUpdateMode QGraphicsView::viewportUpdateMode | ( | ) | const |
Property documentation pending.
|
overrideprotectedvirtual |
Reimplemented from QWidget::wheelEvent().
Reimplemented from QWidget.
|
This property holds the alignment of the scene in the view when the whole scene is visible.
If the whole scene is visible in the view, (i.e., there are no visible scroll bars,) the view's alignment will decide where the scene will be rendered in the view. For example, if the alignment is Qt::AlignCenter, which is default, the scene will be centered in the view, and if the alignment is (Qt::AlignLeft | Qt::AlignTop), the scene will be rendered in the top-left corner of the view.
Properties | Class Methods |
---|---|
read | alignment |
write | setAlignment |
|
This property holds the background brush of the scene.
This property sets the background brush for the scene in this view. It is used to override the scene's own background, and defines the behavior of drawBackground(). To provide custom background drawing for this view, you can reimplement drawBackground() instead.
By default, this property contains a brush with the Qt::NoBrush pattern.
Properties | Class Methods |
---|---|
read | backgroundBrush |
write | setBackgroundBrush |
|
This property holds which parts of the view are cached.
QGraphicsView can cache pre-rendered content in a QPixmap, which is then drawn onto the viewport. The purpose of such caching is to speed up the total rendering time for areas that are slow to render. Texture, gradient and alpha blended backgrounds, for example, can be notably slow to render; especially with a transformed view. The CacheBackground flag enables caching of the view's background.
The cache is invalidated every time the view is transformed. However, when scrolling, only partial invalidation is required.
By default, nothing is cached.
Properties | Class Methods |
---|---|
read | cacheMode |
write | setCacheMode |
|
This property holds the behavior for dragging the mouse over the scene while the left mouse button is pressed.
This property defines what should happen when the user clicks on the scene background and drags the mouse (e.g., scrolling the viewport contents using a pointing hand cursor, or selecting multiple items with a rubber band). The default value, NoDrag, does nothing.
This behavior only affects mouse clicks that are not handled by any item. You can define a custom behavior by creating a subclass of QGraphicsView and reimplementing mouseMoveEvent().
Properties | Class Methods |
---|---|
read | dragMode |
write | setDragMode |
|
This property holds the foreground brush of the scene.
This property sets the foreground brush for the scene in this view. It is used to override the scene's own foreground, and defines the behavior of drawForeground(). To provide custom foreground drawing for this view, you can reimplement drawForeground() instead.
By default, this property contains a brush with the Qt::NoBrush pattern.
Properties | Class Methods |
---|---|
read | foregroundBrush |
write | setForegroundBrush |
|
This property holds whether the view allowed scene interaction.
If enabled, this view is set to allow scene interaction. Otherwise, this view will not allow interaction, and any mouse or key events are ignored (i.e., it will act as a read-only view).
By default, this property is true.
Properties | Class Methods |
---|---|
read | isInteractive |
write | setInteractive |
|
This property holds flags that can be used to tune QGraphicsView's performance.
QGraphicsView uses clipping, extra bounding rect adjustments, and certain other aids to improve rendering quality and performance for the common case graphics scene. However, depending on the target platform, the scene, and the viewport in use, some of these operations can degrade performance.
The effect varies from flag to flag; see the OptimizationFlags documentation for details.
By default, no optimization flags are enabled.
Properties | Class Methods |
---|---|
read | optimizationFlags |
write | setOptimizationFlags |
|
This property holds the default render hints for the view.
These hints are used to initialize QPainter before each visible item is drawn. QPainter uses render hints to toggle rendering features such as antialiasing and smooth pixmap transformation.
QPainter::TextAntialiasing is enabled by default.
Properties | Class Methods |
---|---|
read | renderHints |
write | setRenderHints |
|
This property holds how the view should position the scene when the view is resized.
QGraphicsView uses this property to decide how to position the scene in the viewport when the viewport widget's size changes. The default behavior, NoAnchor, leaves the scene's position unchanged during a resize; the top-left corner of the view will appear to be anchored while resizing.
Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene uses the view alignment to position the scene in the view.
Properties | Class Methods |
---|---|
read | resizeAnchor |
write | setResizeAnchor |
|
This property holds the behavior for selecting items with a rubber band selection rectangle.
This property defines how items are selected when using the RubberBandDrag drag mode.
The default value is Qt::IntersectsItemShape all items whose shape intersects with or is contained by the rubber band are selected.
Properties | Class Methods |
---|---|
read | rubberBandSelectionMode |
write | setRubberBandSelectionMode |
|
This property holds the area of the scene visualized by this view.
The scene rectangle defines the extent of the scene, and in the view's case, this means the area of the scene that you can navigate using the scroll bars.
If unset, or if a null QRectF is set, this property has the same value as QGraphicsScene::sceneRect, and it changes with QGraphicsScene::sceneRect. Otherwise, the view's scene rect is unaffected by the scene.
Note that, although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values, you can choose to use translate() to navigate the scene instead.
By default, this property contains a rectangle at the origin with zero width and height.
Properties | Class Methods |
---|---|
read | sceneRect |
write | cs_setSceneRect |
|
This property holds how the view should position the scene during transformations.
QGraphicsView uses this property to decide how to position the scene in the viewport when the transformation matrix changes, and the coordinate system of the view is transformed. The default behavior, AnchorViewCenter, ensures that the scene point at the center of the view remains unchanged during transformations (e.g., when rotating, the scene will appear to rotate around the center of the view).
Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene uses the view alignment to position the scene in the view.
Properties | Class Methods |
---|---|
read | transformationAnchor |
write | setTransformationAnchor |
|
This property holds how the viewport should update its contents.
QGraphicsView uses this property to decide how to update areas of the scene that have been reexposed or changed. Usually you do not need to modify this property, but there are some cases where doing so can improve rendering performance. See the ViewportUpdateMode documentation for specific details.
The default value is MinimalViewportUpdate, where QGraphicsView will update as small an area of the viewport as possible when the contents change.
Properties | Class Methods |
---|---|
read | viewportUpdateMode |
write | setViewportUpdateMode |