Skip to content
  • 0 Votes
    4 Posts
    2k Views
    B

    @JonB Shifting it to before any other includes got rid of the error.

    There were no other details in the error messsage.

  • 0 Votes
    4 Posts
    1k Views
    JonBJ

    @BigBen said in QProcess not working in QT Creator (using qt version 6.3.0):

    However, p->startCommand("dir C:\\Users") gives me no error and no output.

    Well that is interesting. As I said I only just discovered looking at the docs. It's new in Qt 6.0. I do not use Qt 6, nor Windows, so I cannot comment. If you look at he examples at https://doc.qt.io/qt-6/qprocess.html#startCommand you can see them claiming to issue dir commands that way, that's all I can say.

    I want to ask that in p->start("cmd", { "/c", "dir C:\\Users" });, what does the /c mean in the second argument?

    The Windows/DOS cmd.exe takes various arguments, as you can see from running cmd /?. Including:

    /C Carries out the command specified by string and then terminates

    Basically without the /c it runs an interactive Command Prompt, the command-line console. With the /c it interprets and executes the command line string following it, i.e. your dir .... It does not open a Command Prompt window and it returns to your code immediately after executing the command. dir is built into cmd.exe --- along with many other "simple" commands like echo or mkdir --- there is no external dir.exe file to execute, so we need cmd /c dir to perform it.

  • 0 Votes
    9 Posts
    944 Views
    B

    @JonB

    Thank you for your guidance.
    I was able to solve this issue with your help.

    For others facing this issue:

    The connect() function that worked for me was:

    QObject::connect(&futWatch, &QFutureWatcher<int>::finished, this, &myClass::onFinished);

    And the onFinished() function was the same as suggested by Jon

  • 0 Votes
    1 Posts
    334 Views
    No one has replied