Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Creating project executable and passing command line argument
Forum Updated to NodeBB v4.3 + New Features

Creating project executable and passing command line argument

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anuj nogja
    wrote on last edited by
    #1

    Hi,
    I have created the project in linux. Now i want to create executable of this and has to pass two arguments from command line which will be used in program.
    Ex: ./executablename <arg1><arg2>
    How this can be achieved. Kindly suggest.

    Regards,
    Anuj

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      i assume you mean when you run the .exe ?
      You can use
      http://doc.qt.io/qt-5/qcommandlineparser.html

      Normal c++ handling is also possible
      int main(int argc, char *argv[])

      argv contains the arguments as normal.

      A 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        i assume you mean when you run the .exe ?
        You can use
        http://doc.qt.io/qt-5/qcommandlineparser.html

        Normal c++ handling is also possible
        int main(int argc, char *argv[])

        argv contains the arguments as normal.

        A Offline
        A Offline
        anuj nogja
        wrote on last edited by
        #3

        @mrjj Hi,
        Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
        Thanks in advance...

        mrjjM JonBJ 2 Replies Last reply
        0
        • A anuj nogja

          @mrjj Hi,
          Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
          Thanks in advance...

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @anuj-nogja
          Hi
          Just select the Release kit and build all.
          Then there is an exe in the build folder.

          To run it on other system, you need some DLLS with it.
          That we call a deployment folder.
          You can use the tool
          http://doc.qt.io/qt-5/windows-deployment.html
          to help collect the needed dlls for the exe.

          The .exe CANNOT run without these DLLs in the folder when outside Creator

          1 Reply Last reply
          2
          • A anuj nogja

            @mrjj Hi,
            Like in c... we complie and create exetuable. Like that, how can this be created for qt project?
            Thanks in advance...

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @anuj-nogja said in Creating project executable and passing command line argument:

            Like in c... we complie and create exetuable. Like that, how can this be created for qt project?

            A Qt project is a C++ project. If you use Qt Creator, you compile & create an executable from there, just as you would for any other C project.... Or you can do it all externally from the command-line. There's nothing special for Qt here.

            1 Reply Last reply
            3
            • M Offline
              M Offline
              mchinand
              wrote on last edited by mchinand
              #6

              If you are wondering how add command-line arguments when you run the program from QtCreator; select 'Projects' on the left and then the 'Run' settings for the kit you are building with. One of the options that you can set is the command-line arguments. This is useful for testing your program while developing it and before deploying and distributing it.

              1 Reply Last reply
              3

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved