Important: Please read the Qt Code of Conduct -

[SOLVED] Inter-Process Communication

  • Hi all,

    I want to make an app to migrate MySQL databases, I need to use QProcess since I need mysqldump and mysql to do the trick, but I need to comunicate them.

    My question is, will QSharedMemory do the trick?


  • Lifetime Qt Champion


    What do you mean by "I need to communicate them" ?

  • Hi SGaist, thanks for reply,

    I mean that que QProcess that runs mysqldump pass its output to the QProcess thar runs mysql, so I can migrate the database. Like in this Linux example:

    mysqldump -u USER -p DATABASE | mysql -h DEST_HOST -u root -p123 DEST_DATABASE


  • Moderators

    you need to do the piping by yourself. QProcess provides the necessary methods for reading stdout and setting stdin.
    This enables you to chain the commands like you want to do.

  • Normally shared memory with a timer polling for completion status of the mysqldump process should work ... But if are on Unix or Linux (which is what I assume looking at the database) and you need Signals and slots support you can use the Qt Dbus module.

  • Hi raven-worx, thanks for reply.

    I'll try setStandardOutputProcess and tell you how it goes.


  • Here is the code

    QProcess process1;
    QProcess process2;


    QStringList argumentsProcess1;
    argumentsProcess1 << "--user=USER";
    argumentsProcess1 << "--host=HOST";
    argumentsProcess1 << "--password=PASS";
    argumentsProcess1 << "--port=3306";
    argumentsProcess1 << "mysql";

    QStringList argumentsProcess2;
    argumentsProcess2 << "--user=USER";
    argumentsProcess2 << "--host=HOST_2";
    argumentsProcess2 << "--password=PASS";
    argumentsProcess2 << "--port=3306";
    argumentsProcess2 << "--database=mysql";

    process1.start("mysqldump", argumentsProcess1);
    process2.start("mysql", argumentsProcess2);

Log in to reply