Home > other >  How to use Windows QT to call WSL cmd?
How to use Windows QT to call WSL cmd?

Time:08-31

I'm new to QT and Windows environment programming and tried to integrate some stuffs I developed in Python with another guy in QT. My python code deals with .ods and .xls files by using linux packages gnumeric and libreoffice. I found that WSL may be a convenient way to run my original Python code and it went well after I installed WSL2 Ubuntu.

Then I installed QT5.15.2 with MinGW and try to run my Python code after click a button. I tested in QT Creator and found this line works: QProcess::execute("cmd /c mkdir C:\\Test"); that creates a folder in C. However, this line won't work: QProcess::execute("cmd /c wsl -h >> res.txt"); It can't recognize what wsl is. But I also test the QT MinGW terminal and it recognized wsl. Why it can't recognize in exe? Do I need to select different compiler or debugger? Or any other suggestion such as Docker for this kind of integration? Thank you~

CodePudding user response:

This works with C

system(QString("wsl.exe").toStdString().c_str());

  • Related