[QtXmlPatterns module]
该QAbstractMessageHandler类提供用于处理消息的回调接口。More…
继承QObject。
Methods
__init__ (self, QObject parent = None)
handleMessage (self, QtMsgType type, QString description, QUrl identifier, QSourceLocation sourceLocation)
message (self, QtMsgType type, QString description, QUrl identifier = QUrl(), QSourceLocation sourceLocation = QSourceLocation())
Detailed Description
该QAbstractMessageHandler类提供用于处理消息的回调接口。
QAbstractMessageHandler是提供用于处理消息的回调接口的抽象基类。例如,类QXmlQuery分析和运行的XQuery。当它检测到一个编译或运行时错误,它会生成一个相应的错误信息,而不是输出消息本身,它传递的消息到message( )函数将其QAbstractMessageHandler的。看QXmlQuery.setMessageHandler( ) 。
你通过继承QAbstractMessageHandler和实施创建消息处理程序handleMessage( ) 。然后,将指针传递给你的子类的实例必须生成消息的任何类。该消息通过发送到消息处理程序message( )函数,该函数将它们转发给你的handleMessge ( ) 。其效果是序列化的所有消息的处理,这意味着你的QAbstractMessageHandler子类是线程安全的。
QAbstractMessageHandler的单个实例可以被调用来处理来自多个来源的消息。因此,消息的内容,它是description传递给参数message()和handleMessage( ) ,必须解释在光需要发送消息的上下文。这种情况下被指定的identifier和sourceLocation参数message( )handleMessage( ) 。
Method Documentation
QAbstractMessageHandler.__init__ (self, QObject parent = None)
该parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。
构造一个QAbstractMessageHandler。该parent被传递到QObject基类的构造函数。
QAbstractMessageHandler.handleMessage (self, QtMsgType type, QString description, QUrl identifier, QSourceLocation sourceLocation)
这种方法是抽象的,应在任何子类中重新实现。
这个功能必须由子类来实现。message( )会调用这个函数,传入的参数,type,description,identifier和sourceLocation未修改。
QAbstractMessageHandler.message (self, QtMsgType type, QString description, QUrl identifier = QUrl(), QSourceLocation sourceLocation = QSourceLocation())
将消息发送到这个消息处理程序。type正在发送消息的种类。description是消息的内容。该identifier是标识的消息,是关键解释其他参数的URI 。
通常情况下,这个类是用于报告错误,是这样QXmlQuery,它采用了QAbstractMessageHandler报告编译和运行时XQuery错误。因此,使用一个QUrl作为消息identifier_IS的灵感来自于的解释error handling in the XQuery language。因为_identifier是由一个命名空间URI和本地部分,标识符具有相同本地部分是唯一的。来电者是负责确保identifier是一个有效的QUrl或默认构造QUrl。
sourceLocation在一个资源(即,文件或文件)中检测是否需要报告一个消息,其中,识别一个位置。
这个函数直接调用handleMessage( ) ,传递其所有参数不变。
See also http://www.w3.org/TR/xquery/#errors。