Q3CanvasView Class ReferenceThe Q3CanvasView class provides an on-screen view of a Q3Canvas. More... #include <Q3CanvasView> This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information. Inherits: Q3ScrollView. Public Functions
Reimplemented Protected Functions
Additional Inherited Members
Detailed DescriptionThe Q3CanvasView class provides an on-screen view of a Q3Canvas. A Q3CanvasView is widget which provides a view of a Q3Canvas. If you want users to be able to interact with a canvas view, subclass Q3CanvasView. You might then reimplement Q3ScrollView::contentsMousePressEvent(). For example: void MyCanvasView::contentsMousePressEvent(QMouseEvent* e) { Q3CanvasItemList l = canvas()->collisions(e->pos()); for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { if ((*it)->rtti() == Q3CanvasRectangle::RTTI) qDebug("A Q3CanvasRectangle lies somewhere at this point"); } } The canvas view shows canvas canvas(); this can be changed using 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. For example: QMatrix 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 QMatrix, QPainter::setWorldMatrix(), QtCanvas, and Porting to Graphics View. Member Function Documentation
|