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  · 

QDebug Class Reference
[QtCore module]

The QDebug class provides an output stream for debugging information. More...

 #include <QDebug>

Public Functions


Detailed Description

The QDebug class provides an output stream for debugging information.

QDebug is used whenever the developer needs to write out debugging or tracing information to a device, file, string or console.

Basic Use

In the common case, it is useful to call the qDebug() function to obtain a default QDebug object to use for writing debugging information.

     qDebug() << "Date:" << QDate::currentDate();
     qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
     qDebug() << "Custom coordinate type:" << coordinate;

This constructs a QDebug object using the constructor that accepts a QtMsgType value of QtDebugMsg. Similarly, the qWarning(), qCritical() and qFatal() functions also return QDebug objects for the corresponding message types.

The class also provides several constructors for other situations, including a constructor that accepts a QFile or any other QIODevice subclass that is used to write debugging information to files and other devices. The constructor that accepts a QString is used to write to a string for display or serialization.

Writing Custom Types to a Stream

Many standard types can be written to QDebug objects, and Qt provides support for most Qt value types. To add support for custom types, you need to implement a streaming operator, as in the following example:

 QDebug operator<<(QDebug dbg, const Coordinate &c)
 {
     dbg.nospace() << "(" << c.x() << ", " << c.y() << ")";

     return dbg.space();
 }

This is described in the Debugging Techniques and Creating Custom Qt Types documents.


Member Function Documentation

QDebug::QDebug ( QIODevice * device )

Constructs a debug stream that writes to the given device.

QDebug::QDebug ( QString * string )

Constructs a debug stream that writes to the given string.

QDebug::QDebug ( QtMsgType type )

Constructs a debug stream that writes to the handler for the message type specified by type.

QDebug::QDebug ( const QDebug & other )

Constructs a copy of the other debug stream.

QDebug::~QDebug ()

Flushes any pending data to be written and destroys the debug stream.

QDebug & QDebug::maybeSpace ()

Writes a space character to the debug stream, depending on the last character sent to the stream, and returns a reference to the stream.

If the last character was a space character, this function writes a space character to the stream; otherwise, no characters are written to the stream.

See also space() and nospace().

QDebug & QDebug::nospace ()

Clears the stream's internal flag that records whether the last character was a space and returns a reference to the stream.

See also space() and maybeSpace().

QDebug & QDebug::space ()

Writes a space character to the debug stream and returns a reference to the stream.

The stream will record that the last character sent to the stream was a space.

See also nospace() and maybeSpace().

QDebug & QDebug::operator<< ( QChar t )

Writes the character, t, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( bool t )

Writes the boolean value, t, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( char t )

Writes the character, t, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( signed short i )

Writes the signed short integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( unsigned short i )

Writes then unsigned short integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( signed int i )

Writes the signed integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( unsigned int i )

Writes then unsigned integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( signed long l )

Writes the signed long integer, l, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( unsigned long l )

Writes then unsigned long integer, l, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( qint64 i )

Writes the signed 64-bit integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( quint64 i )

Writes then unsigned 64-bit integer, i, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( float f )

Writes the 32-bit floating point number, f, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( double f )

Writes the 64-bit floating point number, f, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const char * s )

Writes the '\0'-terminated string, s, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const QString & s )

Writes the string, s, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const QStringRef & s )

Writes the string reference, s, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const QLatin1String & s )

Writes the Latin1-encoded string, s, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const QByteArray & b )

Writes the byte array, b, to the stream and returns a reference to the stream.

QDebug & QDebug::operator<< ( const void * p )

Writes a pointer, p, to the stream and returns a reference to the stream.

QDebug & QDebug::operator= ( const QDebug & other )

Assigns the other debug stream to this stream and returns a reference to this stream.

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 64
  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. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. 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
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

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