QCanvasView(3qt)
β¨ QCanvasView(3qt) β¨
okay bestie, so this is the manual page for QCanvasView from Qt 3.3.8, brought to you by Trolltech (the man page itself is dated 2 February 2007, we'll get to that at the end π«Ά). It's a 3qt page, which means it's a Qt library manual. Let's get into it π
πΈ NAME πΈ
QCanvasView β an on-screen view of a QCanvas πβ¨
π SYNOPSIS π
#include <qcanvas.h>
Inherits QScrollView. Yes, she's a widget, she's got lineage π
β¨ Public Members β¨
QCanvasView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )QCanvasView ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )~QCanvasView ()QCanvas * canvas () constvoid setCanvas ( QCanvas * canvas )const QWMatrix & worldMatrix () constconst QWMatrix & inverseWorldMatrix () constbool setWorldMatrix ( const QWMatrix & wm )
π¦ Protected Members π¦
virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int ch )virtual QSize sizeHint () const
π DESCRIPTION π
The QCanvasView class provides an on-screen view of a QCanvas. That's the whole vibe, periodt.
A QCanvasView is a widget which provides a view of a QCanvas. π¨
So like β if you want users to actually be able to interact with a canvas view, you subclass QCanvasView. Then you'd probably reimplement QScrollView::contentsMousePressEvent(). For example, assuming no transformation matrix is set:
void MyCanvasView::contentsMousePressEvent( QMouseEvent* e )
{
QCanvasItemList l = canvas()->collisions(e->pos());
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
if ( (*it)->rtti() == QCanvasRectangle::RTTI )
qDebug("A QCanvasRectangle lies somewhere at this point");
}
}
The canvas view shows canvas canvas(); and bestie, you can change that with setCanvas(). π
A transformation matrix can be used to transform the view of the canvas in various ways, for example, zooming in or out or rotating. Like so:
QWMatrix wm;
wm.scale( 2, 2 ); // Zooms in by 2 times
wm.rotate( 90 ); // Rotates 90 degrees counter clockwise
// around the origin.
wm.translate( 0, -canvas->height() );
// moves the canvas down so what was visible
// before is still visible.
myCanvasView->setWorldMatrix( wm );
Use setWorldMatrix() to set the canvas view's world matrix: you must ensure that the world matrix is invertible. The current world matrix is retrievable with worldMatrix(), and its inversion is retrievable with inverseWorldMatrix(). π
Example:
The following code finds the part of the canvas that is visible in this view, i.e. the bounding rectangle of the view in canvas coordinates.
QRect rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(),
myCanvasView->visibleWidth(), myCanvasView->visibleHeight() );
QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
See also QWMatrix, QPainter::setWorldMatrix(), Graphics Classes, and Image Processing Classes. π
π§ MEMBER FUNCTION DOCUMENTATION π§
QCanvasView::QCanvasView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
Constructs a QCanvasView with parent parent, and name name, using the widget flags f. Heads up though: the canvas view is not associated with a canvas, so you must call setCanvas() to view a canvas. Don't forget, or she's just sitting there with nothing to show π
QCanvasView::QCanvasView ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function. (Classic convenience behavior, we love her π)
Constructs a QCanvasView which views canvas canvas, with parent parent, and name name, using the widget flags f.
QCanvasView::~QCanvasView ()
Destroys the canvas view. The associated canvas is not deleted β important!! She does not take the canvas down with her, no cap π
QCanvas * QCanvasView::canvas () const
Returns a pointer to the canvas which the QCanvasView is currently showing. πΌοΈ
void QCanvasView::drawContents ( QPainter * p, int cx, int cy, int cw, int ch )
[virtual protected]
Repaints part of the QCanvas that the canvas view is showing starting at cx by cy, with a width of cw and a height of ch using the painter p.
Warning: When double buffering is enabled,drawContents()will not respect the current settings of the painter when setting up the painter for the double buffer (e.g.,viewport()andwindow()). Also, be aware thatQCanvas::update()bypassesdrawContents(), which means any reimplementation ofdrawContents()is not called. π¨ like, actually be aware, bestie.
See also QCanvas::setDoubleBuffering().
Reimplemented from QScrollView.
const QWMatrix & QCanvasView::inverseWorldMatrix () const
Returns a reference to the inverse of the canvas view's current transformation matrix. πͺ
See also setWorldMatrix() and worldMatrix().
void QCanvasView::setCanvas ( QCanvas * canvas )
Sets the canvas that the QCanvasView is showing to the canvas canvas. Swapsies β¨
bool QCanvasView::setWorldMatrix ( const QWMatrix & wm )
Sets the transformation matrix of the QCanvasView to wm. The matrix must be invertible (i.e. if you create a world matrix that zooms out by 2 times, then the inverse of this matrix is one that will zoom in by 2 times).
When you use this, you should note that the performance of the QCanvasView will decrease considerably. π¬ lowkey a price to pay, fr fr.
Returns FALSE if wm is not invertable; otherwise returns TRUE.
See also worldMatrix(), inverseWorldMatrix(), and QWMatrix::isInvertible().
Example: canvas/canvas.cpp.
QSize QCanvasView::sizeHint () const
[virtual protected]
Suggests a size sufficient to view the entire canvas. She's suggesting, not demanding π
const QWMatrix & QCanvasView::worldMatrix () const
Returns a reference to the canvas view's current transformation matrix. π
See also setWorldMatrix() and inverseWorldMatrix().
Example: canvas/canvas.cpp.
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
π AUTHOR π
Generated automatically from the source code. (Not a human bestie, a script bestie π€β¨)
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π«Ά
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qcanvasview.3qt) and the Qt version (3.3.8).
aaaand that's the whole page bestie π this was QCanvasView(3qt) from the Qt 3.3.8 docs, published by Trolltech AS on 2 February 2007 β go forth and draw on your canvas, you've got this ππ¦β¨
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms