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. Qt Application with CLI Commands
Forum Updated to NodeBB v4.3 + New Features

Qt Application with CLI Commands

Scheduled Pinned Locked Moved General and Desktop
18 Posts 3 Posters 7.8k 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.
  • C Offline
    C Offline
    croussou
    wrote on last edited by
    #9

    Quite simple indeed. Can I hide the command prompt or software interface while this is taking place? I do not want the user to see that a 3rd party application is behind this...

    Regards,

    croussou

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #10

      I don't believe that a command prompt or anything should appear. It's all handled in the background. It doesn't actually open a command prompt window and type in the commands.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        croussou
        wrote on last edited by
        #11

        Those arguments seem a little tricky...How's the order they should be written? For example the command line command for 7z is "7za a -t7z files.7z text1.txt" to create files.7z with text1.txt inside.

        @QApplication a(argc, argv);

        QObject *parent;
        QString program = "C:\Software\7za920\7za.exe";
        QStringList arguments;
        arguments << "7za a -t7z files.7z text1.txt";
        QProcess *myProcess = new QProcess(parent);
        myProcess->start(program, arguments);
        
        zipfile w;
        w.show();
        
        return a.exec&#40;&#41;;@
        

        Regards,

        croussou

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #12

          @
          QString program = "C:\Software\7za920\7za.exe"; // This is the app
          QStringList arguments;
          arguments << "a" << "-t7z" << "files.7z" << "text1.txt"; // Don't need "7za" here, it's already covered up there.
          @

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            croussou
            wrote on last edited by
            #13

            Hmm...done but it doesn't work...but where do we specify where the .txt file is located? How does the program know where to get it from?

            Regards,

            croussou

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #14

              Well, I would assume that you would know where the file is that you're wanting to work with. Shouldn't you probably just use the full path to it? "/path/to/text1.txt"

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                croussou
                wrote on last edited by
                #15

                Still...

                @QObject *parent;
                QString program = "/Software/7za920/7za.exe";
                QStringList arguments;
                arguments << "a" << "-t7z" << "/Users/croussou_dm4/Desktop/files.7z" << "/Users/croussou_dm4/Desktop/text1.txt";
                QProcess *myProcess = new QProcess(parent);
                myProcess->start(program, arguments);@

                By the way, thanks for your support...

                Regards,

                croussou

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mlong
                  wrote on last edited by
                  #16

                  I'd suggest reading through the docs for QProcess. There are various ways to find the return code of the finished process (was it ok?) or to read from stderr (were there any error messages), and that sort of thing.

                  In the long run, it will be much more beneficial than me or anyone else trying to guess what the problems may be.

                  By the way, you're welcome!

                  Software Engineer
                  My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    croussou
                    wrote on last edited by
                    #17

                    Again thank you very much.

                    I will look into that.

                    Regards,

                    croussou

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlong
                      wrote on last edited by
                      #18

                      Be sure and let us know what you find out!

                      Software Engineer
                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                      1 Reply Last reply
                      0

                      • Login

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