Menu

PythonQt print to console.

Help
Neosettler
2013-05-28
2013-05-29
  • Neosettler

    Neosettler - 2013-05-28

    Greetings,

    Is there any other way of getting PythonQt error handling other than PythonQtScriptingConsole? I'm asking because migrating code from Pyside sometimes requires testing where the QApplication is within the python script and PythonQtScriptingConsole only work when a paint device is present.

    Note: On Windows, AllocConsole(); works well with pure C++ Pyhton but fail to do anything with C++ PyhtonQt.

     
  • Florian Link

    Florian Link - 2013-05-28

    Just enable the Python stdout/err redirection on PythonQt::init() and connect to the signals of PythonQt::self() pythonStdOut/Err. From there you can print to whereever you want.

    Another possibility is to not redirect the output and to build a windows "console" application, then the output will be visible in the dos shell.

     
  • Neosettler

    Neosettler - 2013-05-29

    Thank you Florian for your feedback. Would this be a good approach:

    QObject::connect(PythonQt::self(), SIGNAL(pythonStdOut(const QString&)), this, SLOT(Print(const QString&)));

    void Print::OnPythonQtStdOut(const QString &str)
    {
        // output to console!
    }
    

    Or you have something else in mind?

    Note: The second options works but won't be portable.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.