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. Not to show console window when using system()
Forum Updated to NodeBB v4.3 + New Features

Not to show console window when using system()

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 865 Views 3 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.
  • sierdzioS sierdzio

    OK then:

    system( "cp -pR srcFile dstFile" );

    Here you can simply use QFile::copy().

    sytem( applicationName +"&")

    Here you can use QProcess::startDetached().

    Y Offline
    Y Offline
    ynatynat
    wrote on last edited by
    #5

    @sierdzio
    Thank you for each replacement functions.

    1 Reply Last reply
    0
    • sierdzioS sierdzio

      OK then:

      system( "cp -pR srcFile dstFile" );

      Here you can simply use QFile::copy().

      sytem( applicationName +"&")

      Here you can use QProcess::startDetached().

      Y Offline
      Y Offline
      ynatynat
      wrote on last edited by
      #6

      @sierdzio
      It seems not easy to replace system(cp ...) to QFile::copy() for windows.
      It's fail to copy file or directory to directory under C:.

      sierdzioS 1 Reply Last reply
      0
      • Y ynatynat

        @sierdzio
        It seems not easy to replace system(cp ...) to QFile::copy() for windows.
        It's fail to copy file or directory to directory under C:.

        sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #7

        @ynatynat Please show your code, it's hard to help otherwise.

        Qt can definitely handle Windows paths.

        (Z(:^

        Christian EhrlicherC 1 Reply Last reply
        0
        • sierdzioS sierdzio

          @ynatynat Please show your code, it's hard to help otherwise.

          Qt can definitely handle Windows paths.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @sierdzio looks like he wants to copy a directory.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          Y 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            @sierdzio looks like he wants to copy a directory.

            Y Offline
            Y Offline
            ynatynat
            wrote on last edited by
            #9

            @sierdzio
            @Christian-Ehrlicher

            QString src = "c:\Users\a\data\"
            std::string dst = "C:/Users/a/Documents/data_2023-11-15"
            
            QFile::copy( src , QString::fromStdString(dst));
            
            

            //---------
            [C:/Users/a/Documents/data_2023-11-15 ] is not found after that.
            "src" is a directory, which has some files.
            "dst" is a new directory.

            Christian EhrlicherC 1 Reply Last reply
            0
            • Y ynatynat

              @sierdzio
              @Christian-Ehrlicher

              QString src = "c:\Users\a\data\"
              std::string dst = "C:/Users/a/Documents/data_2023-11-15"
              
              QFile::copy( src , QString::fromStdString(dst));
              
              

              //---------
              [C:/Users/a/Documents/data_2023-11-15 ] is not found after that.
              "src" is a directory, which has some files.
              "dst" is a new directory.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #10

              As you can see in the documentation and also from the word 'file' you can also copy files with this command. You have to write a directory copy by yourself. Use the search function as you are not the first who wants to copy a directory.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              Y 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                As you can see in the documentation and also from the word 'file' you can also copy files with this command. You have to write a directory copy by yourself. Use the search function as you are not the first who wants to copy a directory.

                Y Offline
                Y Offline
                ynatynat
                wrote on last edited by
                #11

                @Christian-Ehrlicher
                Thank you. Isee.
                I found how to copy directory to another directory (including all files).
                https://forum.qt.io/topic/10263/solved-copy-all-files-in-folder-to-another-directory/5

                JonBJ 1 Reply Last reply
                0
                • Y ynatynat has marked this topic as solved on
                • Y ynatynat

                  @Christian-Ehrlicher
                  Thank you. Isee.
                  I found how to copy directory to another directory (including all files).
                  https://forum.qt.io/topic/10263/solved-copy-all-files-in-folder-to-another-directory/5

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

                  @ynatynat
                  Be aware that the post you link to actually removes a file hierarchy! To copy you will need to write something which is called recursively for each child directory you want to copy. There may be alternative posts which are more recent than that one.

                  Y 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @ynatynat
                    Be aware that the post you link to actually removes a file hierarchy! To copy you will need to write something which is called recursively for each child directory you want to copy. There may be alternative posts which are more recent than that one.

                    Y Offline
                    Y Offline
                    ynatynat
                    wrote on last edited by
                    #13

                    @JonB
                    Thank you for advice! I'll search.

                    1 Reply Last reply
                    0
                    • jeremy_kJ Offline
                      jeremy_kJ Offline
                      jeremy_k
                      wrote on last edited by
                      #14

                      C++17's std::filesystem::copy has a recursive option.

                      Asking a question about code? http://eel.is/iso-c++/testcase/

                      1 Reply Last reply
                      2

                      • Login

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