Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can a Mac DynLib Spawn an Async QProcess?



  • Can a Mac dynlib spawn an async QProcess? Here's my trouble:

    • The examples I see on the web show this called from a GUI, and therefore they pass a "this" object on the "new QProcess(this)" call. That doesn't seem to work from a dynlib that isn't a GUI. What do I pass instead?

    • How do I keep a private handle variable on the class for the QProcess so that other functions can use that private variable?

    • This QProcess can take awhile to run (the command line takes awhile). How do I peek into standard output and standard error from it occasionally without doing blocking that locks up the dynlib? How do I know that the process has completed?


  • Lifetime Qt Champion

    Hi,

    QProcess is part of QtCore. The parent can be any QObject or even 0 as long as you handle it's deletion properly.

    What private variable do you have in mind ?

    You have the link readyReadStandardError and readyReadStandardOutput to get data from your QProcess and the finished signal to know when it's done.



  • @SGaist said:

    Hi,

    QProcess is part of QtCore. The parent can be any QObject or even 0 as long as you handle it's deletion properly.

    What private variable do you have in mind ?

    The QProcess that I spawned. You also remind me -- when done, I need to use the "delete" statement on it so that I don't have a memory leak.

    You have the link readyReadStandardError and readyReadStandardOutput to get data from your QProcess and the finished signal to know when it's done.

    How do I connect those signals asynchronously within the Macintosh .dynlib file that I coded?


  • Lifetime Qt Champion

    Creating a shared library on OS X using Qt follows the same rules as creating an application. You don't have special handling to do. Create your classes like you would for your application.


Log in to reply