Important: Please read the Qt Code of Conduct -

Qt creator: howto pass command line arguments to the program you are writing?

  • Hi All,
    I am writing a console Qt application that accepts command-line options. Therefore I'm using QCommandLineParser. I write the program in Qt creator, and use the F5 key to start debugging. Now my program is started in the debugger, but this way I'm not able to set any command line options, and I cannot see if my program handles them correctly.
    Second option is to build the program in Qt creator, then open cmd.exe, goto the build directory, and then run the program from there. This way I can set command line options for my application, but then I can not debug the program.
    Is there a way to tell QtCreator to give my program a set of command line options?
    Is there a way to set a breakpoint my program, so I can start it with command line options from cmd.exe, and then attach with the debugger in QtCreator, and then step trough the program?
    My versions:
    Windows 7 enterprise SP1 64 bit
    Qt Creator 3.6.0 Based on Qt 5.5.1 (MSVC 2013, 32 bit)
    QT5.5, mingw492_32

  • Lifetime Qt Champion

    Hi and welcome
    I think you can use this

  • Thank you.
    I feel a bit stupid for not finding that myself, but I'm very glad you answered me this fast.

  • Lifetime Qt Champion

    oh no worries you provided good info on platform and versions so
    +1 for that anyways :)

  • Just to be sure, my question is for QtCreator 4.2.
    This topic "Qt creator: how to pass command line arguments to the program you are writing" is marked as SOLVED, but the solution is not available to view or read.
    Can you please re-post the solution?

  • Lifetime Qt Champion


    Hi and welcome

    If you mean where to write the command line arguments , the image i posted higher up
    shows where to find it.

  • I cannot see a solution image. Apparently, my secure work environment is blocking some image types again on the non-secure network. Normally, I can see PNG and JPG.
    I will check it again from home.

  • Lifetime Qt Champion

    oh that was new :)
    Projects (left side, under debug)
    Then Run Settings
    then there is an edit "command line arguments"

  • Yes, found it. Problem solved.

Log in to reply