Hello

For Qt4, QtCore.qInstallMsgHandler installs a Qt message handler with the following signature:

    void myMsgHandler(QtMsgType, const char *);

Using PyQt4 with Qt4, this correctly results in the second argument being passed as a python bytes object (for both the v1 and v2 apis).

However, for Qt5 it only does this when using Python3 with the v2 api. For Python3 with the v1 api, it passes a QString, and for Python2 it either passes a QString (v1 api) or a python unicode object (v2 api).

I realize that QtCore.qInstallMsgHandler has been deprecated in Qt5, but it would still be great if this could be fixed at some point.

Simple test script:

    import sys, sip
    sip.setapi('QString', int(sys.argv[1]) if sys.argv[1:] else 1)
    from PyQt4 import QtGui, QtCore

    app = QtGui.QApplication([])

    def handler(kind, msg):
        print('API v%s: %s, %s' % (
            sip.getapi('QString'), type(kind), type(msg)))

    QtCore.qInstallMsgHandler(handler)
    app.desktop().screenGeometry(None)

--
Regards
Baz Walter
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to