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  · 

Qt 3 Support Members for QPainter

The following class members are part of the Qt 3 support layer. They are provided to help you port old code to Qt 4. We advise against using them in new code.

Public Functions

  • const QColor & backgroundColor () const
  • bool begin ( QPaintDevice * device, const QWidget * init )
  • QRect boundingRect ( const QRect & rectangle, int flags, const QString & text, int length )
  • QRect boundingRect ( int x, int y, int width, int height, int flags, const QString & text, int length )
  • void drawConvexPolygon ( const QPolygonF & polygon, int index, int count = -1 )
  • void drawConvexPolygon ( const QPolygon & polygon, int index, int count = -1 )
  • void drawCubicBezier ( const QPolygon & controlPoints, int index = 0 )
  • void drawLineSegments ( const QPolygon & polygon, int index = 0, int count = -1 )
  • void drawPoints ( const QPolygon & polygon, int index, int count = -1 )
  • void drawPolygon ( const QPolygonF & polygon, bool winding, int index = 0, int count = -1 )
  • void drawPolygon ( const QPolygon & polygon, bool winding, int index = 0, int count = -1 )
  • void drawPolyline ( const QPolygon & polygon, int index, int count = -1 )
  • void drawText ( int x, int y, const QString & text, int pos, int length )
  • void drawText ( const QPoint & point, const QString & text, int pos, int length )
  • void drawText ( int x, int y, const QString & text, int length )
  • void drawText ( const QPoint & point, const QString & text, int length )
  • void drawText ( const QRect & rectangle, int flags, const QString & text, int length, QRect * br = 0 )
  • void drawText ( int x, int y, int width, int height, int flags, const QString & text, int length, QRect * br = 0 )
  • bool hasViewXForm () const
  • bool hasWorldXForm () const
  • void resetXForm ()
  • void setBackgroundColor ( const QColor & color )
  • void setViewXForm ( bool enabled )
  • void setWorldXForm ( bool enabled )
  • qreal translationX () const
  • qreal translationY () const
  • QPoint xForm ( const QPoint & point ) const
  • QRect xForm ( const QRect & rectangle ) const
  • QPolygon xForm ( const QPolygon & polygon ) const
  • QPolygon xForm ( const QPolygon & polygon, int index, int count ) const
  • QPoint xFormDev ( const QPoint & point ) const
  • QRect xFormDev ( const QRect & rectangle ) const
  • QPolygon xFormDev ( const QPolygon & polygon ) const
  • QPolygon xFormDev ( const QPolygon & polygon, int index, int count ) const

Static Public Members

  • void redirect ( QPaintDevice * pdev, QPaintDevice * replacement )
  • QPaintDevice * redirect ( QPaintDevice * pdev )

Member Function Documentation

const QColor & QPainter::backgroundColor () const

Use background() and QBrush::color() instead.

For example, if you have code like

 QColor myColor = backgroundColor();

you can rewrite it as

 QColor myColor = background().color();

Note that the background can be a complex brush such as a texture or a gradient.

See also setBackgroundColor().

bool QPainter::begin ( QPaintDevice * device, const QWidget * init )

Use begin() instead.

If the paint device is a QWidget, QPainter is initialized after the widget's settings automatically. Otherwise, you must call the initFrom() function to initialize the painters pen, background and font to the same as any given widget.

For example, if you have code like

 QPainter painter(this);
 painter.begin(device, init);

you can rewrite it as

 QPainter painter(this);
 painter.begin(device);
 painter.initFrom(init);

QRect QPainter::boundingRect ( const QRect & rectangle, int flags, const QString & text, int length )

Returns the bounding rectangle for the given length of the text constrained by the provided rectangle.

Use boundingRect() combined with QString::left() instead.

For example, if you have code like

 QRect rectangle = boundingRect(rect, flags, text, length);

you can rewrite it as

 QRect rectangle = boundingRect(rect, flags, text.left(length));

QRect QPainter::boundingRect ( int x, int y, int width, int height, int flags, const QString & text, int length )

Returns the bounding rectangle for the given length of the text constrained by the rectangle that begins at point (x, y) with the given width and height.

Use boundingRect() combined with QString::left() instead.

For example, if you have code like

 QRect rectangle = boundingRect(x, y, width, height, flags, text, length);

you can rewrite it as

 QRect rectangle = boundingRect(x, y, width, height, flags, text.left(length));

void QPainter::drawConvexPolygon ( const QPolygonF & polygon, int index, int count = -1 )

This is an overloaded function.

Use drawConvexPolygon() combined with QPolygonF::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawConvexPolygon(polygon, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;

 QPainter painter(this);
 painter.drawConvexPolygon(polygon.constData() + index, pointCount);

void QPainter::drawConvexPolygon ( const QPolygon & polygon, int index, int count = -1 )

This is an overloaded function.

Use drawConvexPolygon() combined with QPolygon::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawConvexPolygon(polygon, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;

 QPainter painter(this);
 painter.drawConvexPolygon(polygon.constData() + index, pointCount);

void QPainter::drawCubicBezier ( const QPolygon & controlPoints, int index = 0 )

Draws a cubic Bezier curve defined by the controlPoints, starting at controlPoints[index] (index defaults to 0). Points after controlPoints[index + 3] are ignored. Nothing happens if there aren't enough control points.

Use strokePath() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawCubicBezier(controlPoints, index)

you can rewrite it as

 QPainterPath path;
 path.moveTo(controlPoints.at(index));
 path.cubicTo(controlPoints.at(index+1),
                     controlPoints.at(index+2),
                     controlPoints.at(index+3));

 QPainter painter(this);
 painter.strokePath(path, painter.pen());

void QPainter::drawLineSegments ( const QPolygon & polygon, int index = 0, int count = -1 )

Draws count separate lines from points defined by the polygon, starting at polygon[index] (index defaults to 0). If count is -1 (the default) all points until the end of the array are used.

Use drawLines() combined with QPolygon::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawLineSegments(polygon, index, count);

you can rewrite it as

 int lineCount = (count == -1) ?  (polygon.size() - index) / 2  : count;

 QPainter painter(this);
 painter.drawLines(polygon.constData() + index * 2, lineCount);

void QPainter::drawPoints ( const QPolygon & polygon, int index, int count = -1 )

This is an overloaded function.

Draws count points in the vector polygon starting on index using the current pen.

Use drawPoints() combined with QPolygon::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawPoints(polygon, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;

 QPainter painter(this);
 painter.drawPoints(polygon.constData() + index, pointCount);

void QPainter::drawPolygon ( const QPolygonF & polygon, bool winding, int index = 0, int count = -1 )

This is an overloaded function.

Use drawPolygon() combined with QPolygonF::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawPolygon(polygon, winding, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;
 int fillRule = winding ? Qt::WindingFill : Qt::OddEvenFill;

 QPainter painter(this);
 painter.drawPolygon( polygon.constData() + index, pointCount, fillRule);

void QPainter::drawPolygon ( const QPolygon & polygon, bool winding, int index = 0, int count = -1 )

This is an overloaded function.

Use drawPolygon() combined with QPolygon::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawPolygon(polygon, winding, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;
 int fillRule = winding ? Qt::WindingFill : Qt::OddEvenFill;

 QPainter painter(this);
 painter.drawPolygon( polygon.constData() + index, pointCount, fillRule);

void QPainter::drawPolyline ( const QPolygon & polygon, int index, int count = -1 )

This is an overloaded function.

Draws the polyline defined by the count lines of the given polygon starting at index (index defaults to 0).

Use drawPolyline() combined with QPolygon::constData() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawPolyline(polygon, index, count);

you can rewrite it as

 int pointCount = (count == -1) ?  polygon.size() - index : count;

 QPainter painter(this);
 painter.drawPolyline(polygon.constData() + index, pointCount);

void QPainter::drawText ( int x, int y, const QString & text, int pos, int length )

Use drawText() combined with QString::mid() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(x, y, text, pos, length);

you can rewrite it as

 QPainter painter(this);
 painter.drawText(x, y, text.mid(pos, length));

void QPainter::drawText ( const QPoint & point, const QString & text, int pos, int length )

Use drawText() combined with QString::mid() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(point, text, pos, length);

you can rewrite it as

 QPainter painter(this);
 painter.drawText(point, text.mid(pos, length));

void QPainter::drawText ( int x, int y, const QString & text, int length )

Use drawText() combined with QString::left() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(x, y, text, length);

you can rewrite it as

 QPainter painter(this);
 painter.drawText(x, y, text.left(length));

void QPainter::drawText ( const QPoint & point, const QString & text, int length )

Use drawText() combined with QString::left() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(point, text, length);

you can rewrite it as

 QPainter painter(this);
 painter.drawText(point, text.left(length));

void QPainter::drawText ( const QRect & rectangle, int flags, const QString & text, int length, QRect * br = 0 )

Use drawText() combined with QString::left() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(rectangle, flags, text, length, br );

you can rewrite it as

 QPainter painter(this);
 painter.drawText(rectangle, flags, text.left(length), br );

void QPainter::drawText ( int x, int y, int width, int height, int flags, const QString & text, int length, QRect * br = 0 )

Use drawText() combined with QString::left() instead.

For example, if you have code like

 QPainter painter(this);
 painter.drawText(x, y, width, height, flags, text, length, br );

you can rewrite it as

 QPainter painter(this);
 painter.drawText(x, y, width, height, flags, text.left(length), br );

bool QPainter::hasViewXForm () const

Use viewTransformEnabled() instead.

bool QPainter::hasWorldXForm () const

Use worldMatrixEnabled() instead.

void QPainter::redirect ( QPaintDevice * pdev, QPaintDevice * replacement )   [static]

Use setRedirected() instead.

QPaintDevice * QPainter::redirect ( QPaintDevice * pdev )   [static]

Use redirected() instead.

void QPainter::resetXForm ()

Use resetMatrix() instead.

void QPainter::setBackgroundColor ( const QColor & color )

Use setBackground() instead.

See also backgroundColor().

void QPainter::setViewXForm ( bool enabled )

Use setViewTransformEnabled() instead.

See also hasViewXForm().

void QPainter::setWorldXForm ( bool enabled )

Use setWorldMatrixEnabled() instead.

See also hasWorldXForm().

qreal QPainter::translationX () const

Use the worldMatrix() combined with QMatrix::dx() instead.

For example, if you have code like

 QPainter painter(this);
 qreal x = painter.translationX();

you can rewrite it as

 QPainter painter(this);
 qreal x = painter.worldMatrix().dx();

qreal QPainter::translationY () const

Use the worldMatrix() combined with QMatrix::dy() instead.

For example, if you have code like

 QPainter painter(this);
 qreal y = painter.translationY();

you can rewrite it as

 QPainter painter(this);
 qreal y = painter.worldMatrix().dy();

QPoint QPainter::xForm ( const QPoint & point ) const

Use combinedTransform() instead.

QRect QPainter::xForm ( const QRect & rectangle ) const

This is an overloaded function.

Use combinedTransform() instead of this function and call mapRect() on the result to obtain a QRect.

QPolygon QPainter::xForm ( const QPolygon & polygon ) const

This is an overloaded function.

Use combinedTransform() instead.

QPolygon QPainter::xForm ( const QPolygon & polygon, int index, int count ) const

This is an overloaded function.

Use combinedTransform() combined with QPolygon::mid() instead.

For example, if you have code like

 QPainter painter(this);
 QPolygon transformed = painter.xForm(polygon, index, count)

you can rewrite it as

 QPainter painter(this);
 QPolygon transformed = polygon.mid(index, count) * painter.combinedMatrix();

QPoint QPainter::xFormDev ( const QPoint & point ) const

This is an overloaded function.

Use combinedTransform() combined with QMatrix::inverted() instead.

For example, if you have code like

 QPainter painter(this);
 QPoint transformed = painter.xFormDev(point);

you can rewrite it as

 QPainter painter(this);
 QPoint transformed = point * painter.combinedMatrix().inverted();

QRect QPainter::xFormDev ( const QRect & rectangle ) const

This is an overloaded function.

Use mapRect() combined with QMatrix::inverted() instead.

For example, if you have code like

 QPainter painter(this);
 QRect transformed = painter.xFormDev(rectangle);

you can rewrite it as

 QPainter painter(this);
 QRect transformed = painter.combinedMatrix().inverted(rectangle);

QPolygon QPainter::xFormDev ( const QPolygon & polygon ) const

This is an overloaded function.

This is an overloaded function.

Use combinedMatrix() combined with QMatrix::inverted() instead.

For example, if you have code like

 QPainter painter(this);
 QPolygon transformed = painter.xFormDev(rectangle);

you can rewrite it as

 QPainter painter(this);
 QPolygon transformed = polygon * painter.combinedMatrix().inverted();

QPolygon QPainter::xFormDev ( const QPolygon & polygon, int index, int count ) const

This is an overloaded function.

Use combinedMatrix() combined with QPolygon::mid() and QMatrix::inverted() instead.

For example, if you have code like

 QPainter painter(this);
 QPolygon transformed = painter.xFormDev(polygon, index, count);

you can rewrite it as

 QPainter painter(this);
 QPolygon transformed = polygon.mid(index, count) * painter.combinedMatrix().inverted();

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 23
  2. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 45
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  6. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 50
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 23
  5. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 45
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
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.5
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