Encountering issues while trying to start a command line process (openoffice.org) from inside Qt program

  • Hello everyone,

    I'm trying to run a command from inside Qt. I would like to do it like fire and forget, meaning i don't need the program to wait for my process to stop, before continuing. In essence, the openoffice.org process I start applies a macro on a document used as template.
    In essence this code work perfectly in a bash shell:
    openoffice.org3 "macro:///Standard.Module1.findandreplace" template.doc
    or as
    openoffice.org3 template.doc "macro:///Standard.Module1.findandreplace"

    The trouble is that when trying to do the same from inside the Qt program (as explained in QProcess help page) it's not the same success.

    QString parameter="template.doc"
    QString program = "openoffice.org3 "; // tried also with QString program = "/usr/bin/openoffice.org3 "; same results
    QStringList arguments;
    arguments <<parameter<<" "macro:///Standard.Module1.findandreplace" ";

            QProcess *myProcess = new QProcess();// tried also with ... new QProcess(this);
            myProcess->start(program, arguments);


    Any ideas on this?; From what i understood, all you have to do is prepare the args list for the program, which in this case is the macro and the template file.

    I get no error.

    Thank you,

  • Moderators

    If you don't want to wait for the process to finish, use QProcess::startDetached(). Why are you adding a space after the program name?

    You can try adding the whole line (program name + arguments) to the first parameter of QProcess::start(), leaving the arguments QStringList empty. That sometimes works better.

  • Hello sierdzio,

    Thank you very much for your recommendation. It was magnificent. Now I have an other issue, but this is not related to Qt.
    When Openoffice starts it gives me this error:
    "BASIC runtime error.
    Property or method not found: createReplaceDescriptor"

    It is very strange, because when I open the file manually and go to Tools -> Macros -> Run Macro and I select findandreplace it works perfectly.
    If any clues, greatly appreciated (though again is not related to Qt)


Log in to reply

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