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  · 

QAbstractMessageHandler Class Reference

The QAbstractMessageHandler class provides a callback interface for handling messages. More...

 #include <QAbstractMessageHandler>

Inherits: QObject.

Inherited by:

Note: All functions in this class are thread-safe.

This class was introduced in Qt 4.4.

Public Functions

QAbstractMessageHandler ( QObject * parent = 0 )
virtual ~QAbstractMessageHandler ()
void message ( QtMsgType type, const QString & description, const QUrl & identifier = QUrl(), const QSourceLocation & sourceLocation = QSourceLocation() )
  • 29 public functions inherited from QObject

Protected Functions

virtual void handleMessage ( QtMsgType type, const QString & description, const QUrl & identifier, const QSourceLocation & sourceLocation ) = 0
  • 7 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject

Detailed Description

The QAbstractMessageHandler class provides a callback interface for handling messages.

QAbstractMessageHandler is an abstract base class that provides a callback interface for handling messages. For example, class QXmlQuery parses and runs an XQuery. When it detects a compile or runtime error, it generates an appropriate error message, but rather than output the message itself, it passes the message to the message() function of its QAbstractMessageHandler. See QXmlQuery::setMessageHandler().

You create a message handler by subclassing QAbstractMessageHandler and implementing handleMessage(). You then pass a pointer to an instance of your subclass to any classes that must generate messages. The messages are sent to the message handler via the message() function, which forwards them to your handleMessge(). The effect is to serialize the handling of all messages, which means your QAbstractMessageHandler subclass is thread safe.

A single instance of QAbstractMessageHandler can be called on to handle messages from multiple sources. Hence, the content of a message, which is the description parameter passed to message() and handleMessage(), must be interpreted in light of the context that required the message to be sent. That context is specified by the identifier and sourceLocation parameters to message() handleMessage().

Member Function Documentation

QAbstractMessageHandler::QAbstractMessageHandler ( QObject * parent = 0 )

Constructs a QAbstractMessageHandler. The parent is passed to the QObject base class constructor.

QAbstractMessageHandler::~QAbstractMessageHandler () [virtual]

Destructs this QAbstractMessageHandler.

void QAbstractMessageHandler::handleMessage ( QtMsgType type, const QString & description, const QUrl & identifier, const QSourceLocation & sourceLocation ) [pure virtual protected]

This function must be implemented by the sub-class. message() will call this function, passing in its parameters, type, description, identifier and sourceLocation unmodified.

void QAbstractMessageHandler::message ( QtMsgType type, const QString & description, const QUrl & identifier = QUrl(), const QSourceLocation & sourceLocation = QSourceLocation() )

Sends a message to this message handler. type is the kind of message being sent. description is the message content. The identifier is a URI that identifies the message and is the key to interpreting the other arguments.

Typically, this class is used for reporting errors, as is the case for QXmlQuery, which uses a QAbstractMessageHandler to report compile and runtime XQuery errors. Hence, using a QUrl as the message identifier is was inspired by the explanation of error handling in the XQuery language. Because the identifier is composed of a namespace URI and a local part, identifiers with the same local part are unique. The caller is responsible for ensuring that identifier is either a valid QUrl or a default constructed QUrl.

sourceLocation identifies a location in a resource (i.e., file or document) where the need for reporting a message was detected.

This function unconditionally calls handleMessage(), passing all its parameters unmodified.

See also http://www.w3.org/TR/xquery/#errors.

Publicit�

Best Of

Actualit�s les plus lues

Semaine
Mois
Ann�e
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la sp�cification pour la conception d'applications parall�les C++ utilisant le GPU 22
  2. Les d�veloppeurs ignorent-ils trop les failles d�couvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. 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
  4. � Quelque chose ne va vraiment pas avec les d�veloppeurs "modernes" �, un d�veloppeur � "l'ancienne" critique la multiplication des biblioth�ques 12
  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. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil d�claratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveaut�s de C++11 Visual C++ doit-il rapidement int�grer ? Donnez-nous votre avis 10
Page suivante

Le Qt Developer Network au hasard

Logo

Compiler l'add-in Qt de Visual Studio

Le Qt Developer Network est un r�seau de d�veloppeurs Qt anglophone, o� ils peuvent partager leur exp�rience sur le framework. 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