how can I join and run a program when starting application?
-
Hi,
Use QProcess to run your python script.
One thing you can do is give that script a parameter so you manage where the generated file goes from your main application and you can retrieve it's content.
One other possibility is to give your python script the option of printing these information on the standard output and still using
QProcess
you can directly get that information back into your main application without the need to generate a file. -
Can you explain more precisely what you are trying to run ?
-
@SGaist I'm trying to run a file that takes the name of the cpu and gpu and the gpu corporation "NVIDIA OR AMD"
But does not it have a way in which the program takes the root directory where it is automatically? because then I just need to speak the folder where the executable is
-
@Nathan-Miguel
It's getting really unclear (to me at least) what you are asking now. Is it about specifying the path to an executable you want to run? Is it about passing arguments to it? What|
does the command have in it? Why not at least tell us exactly what command you're trying to run?!If you have an external command you have written, you might prefer to just have it write whatever to its standard output rather than to a file which you have to create somewhere. You can then use https://doc.qt.io/qt-5/qprocess.html#readAllStandardOutput to read back the text and not have to have file creation & reading. And BTW creating dynamic/temporary files in the folder where an executable lives, if that is what you are proposing to do, is not a good idea.
-
@JonB I managed to make the program run, but the txt file is being created in the wrong place
rootdir: E:\Git\Denoiser-Script\QML_C++\build-Denosier-Desktop_Qt_5_12_3_MSVC2017_64bit2-Debug\debug
location where the file should exit: E:\Git\Denoiser-Script\QML_C++\build-Denosier-Desktop_Qt_5_12_3_MSVC2017_64bit2-Debug\debug\sysinfo
location of file output: E:\Git\Denoiser-Script\QML_C++\build-Denosier-Desktop_Qt_5_12_3_MSVC2017_64bit2-Debug
QString systeminfo::getsysHardware() { QString rootDir = QCoreApplication::applicationDirPath(); QString appDirWindows = "/sysinfo/main.exe"; QString appDirLinux = "/sysinfo/main"; QString output; QString sysName = getsysType(); QProcess process; if (sysName == "WINDOWS") { process.start(rootDir+appDirWindows); process.waitForFinished(); } else if (sysName == "LINUX") { } return rootDir; }
-
@Nathan-Miguel
But it is the process you run (main.exe
) which creates thissysteminfo.txt
in some directory, is it not? Yet you are showing the code of your Qt application which runs themain.exe
? Are you now talking about what the current directory will be for themain.exe
you run from your Qt program (perhaps because it createssysteminfo.txt
without specifying a path)?? I'm lost....As I suggested before, this would still be simpler anyway if you chose not to do it via a temporary file somewhere in your executable's directory area. Which is waiting to bite you if & when you distribute your application. But as you please.
-
This post is deleted!
-
As I said/suspevted:
-
You show us the code of your Qt application, which does not create the file, so it does not help.
-
Nowhere do you you show whatever code does create the file, so since we cannot see that we cannot advise what it is you need to do.
-
I wrote above:
Are you now talking about what the current directory will be for the
main.exe
you run from your Qt program (perhaps because it createssysteminfo.txt
without specifying a path)??but you didn't reply to that. If you want help, you'll need to provide information.
-