Qt output too verbose



  • Hi there,

    How can I adjust the verbosity of applications that use Qt? I'm using the Qt installed by package manager in Ubuntu 12.04 lts. For instance, all my applications print stuff to the terminal:

    @
    Got bus address: "unix:abstract=/tmp/dbus-uYtYuIHkwF,guid=bf09af5765943413637ce5a500000313"
    Connected to accessibility bus at: "unix:abstract=/tmp/dbus-uYtYuIHkwF,guid=bf09af5765943413637ce5a500000313"
    Registered DEC: true
    Registered event listener change listener: true
    @

    And using ui features causes more stuff to print:

    @
    QSpiAccessible::accessibleEvent not handled: "6" obj: QMenu(0x10902c0, name = "menuFile") "menuFile"
    QSpiAccessible::accessibleEvent not handled: "7" obj: QMenu(0x10902c0, name = "menuFile") "menuFile"
    @

    Is there a way to disable this log?

    Thanks.



  • Install your own "dummy" message handler:

    @void myMessageOutput(QtMsgType type, const char *msg)
    {
    /do nothing, i.e. discard message completely/
    }

    int main(int argc, char **argv)
    {
    qInstallMsgHandler(myMessageOutput);

    /* ... */
    

    }@

    --

    See also:
    http://qt-project.org/doc/qt-4.8/qtglobal.html#qInstallMsgHandler



  • Thanks for the answer! Although, I don't understand why this is necessary. When running the same application on two difference machines, only one of them prints messages from Qt in such a verbose way. Why is this?



  • If you don't install your own message handler, the default one writes the output the STDOUT stream. On Linux, if you run a GUI application from the terminal, the STDOUT becomes visible there. If you run the GUI application without a terminal (e.g. from Nautilus) you simply don't see the STDOUT anywhere (it probably goes to /dev/null). And on Windows, the STDOUT of GUI applications is discarded anyway, even if you run them from a console.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.