简体   繁体   中英

How to use Windows QT to call WSL cmd?

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~

This works with C

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM