Not to show console window when using system()
-
@ynatynat use
qDebug()
,printf()
,QProcess
etc. or some winapi methods. It's hard to say exactly what you need when we don't know what you want to achieve. What do you usesystem()
for? -
OK then:
system( "cp -pR srcFile dstFile" );
Here you can simply use
QFile::copy()
.sytem( applicationName +"&")
Here you can use
QProcess::startDetached()
. -
@ynatynat Please show your code, it's hard to help otherwise.
Qt can definitely handle Windows paths.
-
@sierdzio looks like he wants to copy a directory.
-
@sierdzio
@Christian-EhrlicherQString 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. -
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.
-
@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 -
-
@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. -
C++17's std::filesystem::copy has a recursive option.
11/14