Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3CanvasView Class Reference

The 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

Q3CanvasView ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )
Q3CanvasView ( Q3Canvas * canvas, QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )
~Q3CanvasView ()
Q3Canvas * canvas () const
const QMatrix & inverseWorldMatrix () const
void setCanvas ( Q3Canvas * canvas )
bool setWorldMatrix ( const QMatrix & wm )
const QMatrix & worldMatrix () const
  • 49 public functions inherited from Q3ScrollView
  • 4 public functions inherited from Q3Frame
  • 14 public functions inherited from QFrame
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Reimplemented Protected Functions

virtual void drawContents ( QPainter * p, int cx, int cy, int cw, int ch )
virtual QSize sizeHint () const
  • 26 protected functions inherited from Q3ScrollView
  • 5 protected functions inherited from Q3Frame
  • 3 protected functions inherited from QFrame
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 10 properties inherited from Q3ScrollView
  • 2 properties inherited from Q3Frame
  • 6 properties inherited from QFrame
  • 58 properties inherited from QWidget
  • 1 property inherited from QObject
  • 8 public slots inherited from Q3ScrollView
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 5 signals inherited from Q3ScrollView
  • 1 signal inherited from QWidget
  • 1 signal inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 26 protected functions inherited from Q3ScrollView
  • 5 protected functions inherited from Q3Frame
  • 3 protected functions inherited from QFrame
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

Detailed Description

The 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

Q3CanvasView::Q3CanvasView ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )

Constructs a Q3CanvasView with parent parent, and name name, using the widget flags f. The canvas view is not associated with a canvas, so you must to call setCanvas() to view a canvas.

Q3CanvasView::Q3CanvasView ( Q3Canvas * canvas, QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0 )

This is an overloaded function.

Constructs a Q3CanvasView which views canvas canvas, with parent parent, and name name, using the widget flags f.

Q3CanvasView::~Q3CanvasView ()

Destroys the canvas view. The associated canvas is not deleted.

Q3Canvas * Q3CanvasView::canvas () const

Returns a pointer to the canvas which the Q3CanvasView is currently showing.

See also setCanvas().

void Q3CanvasView::drawContents ( QPainter * p, int cx, int cy, int cw, int ch ) [virtual protected]

Reimplemented from Q3ScrollView::drawContents().

Repaints part of the Q3Canvas 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.

const QMatrix & Q3CanvasView::inverseWorldMatrix () const

Returns a reference to the inverse of the canvas view's current transformation matrix.

See also setWorldMatrix() and worldMatrix().

void Q3CanvasView::setCanvas ( Q3Canvas * canvas )

Sets the canvas that the Q3CanvasView is showing to the canvas canvas.

See also canvas().

bool Q3CanvasView::setWorldMatrix ( const QMatrix & wm )

Sets the transformation matrix of the Q3CanvasView 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 Q3CanvasView will decrease considerably.

Returns false if wm is not invertable; otherwise returns true.

See also worldMatrix(), inverseWorldMatrix(), and QMatrix::isInvertible().

QSize Q3CanvasView::sizeHint () const [virtual protected]

Reimplemented from QWidget::sizeHint().

Suggests a size sufficient to view the entire canvas.

const QMatrix & Q3CanvasView::worldMatrix () const

Returns a reference to the canvas view's current transformation matrix.

See also setWorldMatrix() and inverseWorldMatrix().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le blog Digia au hasard

Logo

Déploiement d'applications Qt Commercial sur les tablettes Windows 8

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.7
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web