在 Qt 中使用 windows 进程时出现问题
Issue when using a windows process in Qt
我正在尝试在 Qt Creator 中编写程序,我想在其中将 .hex 文件更新为 arduino。我已经用 C# 完成了这个程序,但是在 QT 中调用 avrdude 时遇到了一些问题。我尝试了两种选择:
我的第一次尝试:
process = new QProcess(this);
process->start("avrdude -Cavrdude.conf.txt -v -v -v -v -patmega328p -arduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i", 0);
process->waitForFinished(-1);
QByteArray stdout = process.readAllStandardOutput();
QByteArray stderr = process->readAllStandardError();
我的第二次尝试:
QString exePath = "avrdude";
QString arguments = "-Cavrdude.conf.txt -v -v -v -v -patmega328p -carduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i";
#ifdef Q_OS_WIN32
ShellExecuteW(NULL, NULL, (LPCWSTR)exePath.toStdWString().data(), (LPCWSTR)arguments.toStdWString().data(), NULL, SW_HIDE);
#endif
我想知道是否有人知道为什么我的代码什么都不做,或者我可以使用一些解决方案。
也许试试 this one:
QProcess::execute( /*program*/, /*arguments*/ );
路径中有avrdude
吗?如果不是,您可以在执行该过程之前调用 setWorkingDirectory
或将其添加到路径中。为了检查它,打开命令行,cd
进入你的Qt
应用程序的二进制文件夹并输入命令:
avrdude -Cavrdude.conf.txt -v -v -v -v -patmega328p -arduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i", 0
是运行吗?如果不是,你得到的错误是什么?
您也可以使用error
函数获取最后一个错误。
我正在尝试在 Qt Creator 中编写程序,我想在其中将 .hex 文件更新为 arduino。我已经用 C# 完成了这个程序,但是在 QT 中调用 avrdude 时遇到了一些问题。我尝试了两种选择:
我的第一次尝试:
process = new QProcess(this);
process->start("avrdude -Cavrdude.conf.txt -v -v -v -v -patmega328p -arduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i", 0);
process->waitForFinished(-1);
QByteArray stdout = process.readAllStandardOutput();
QByteArray stderr = process->readAllStandardError();
我的第二次尝试:
QString exePath = "avrdude";
QString arguments = "-Cavrdude.conf.txt -v -v -v -v -patmega328p -carduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i";
#ifdef Q_OS_WIN32
ShellExecuteW(NULL, NULL, (LPCWSTR)exePath.toStdWString().data(), (LPCWSTR)arguments.toStdWString().data(), NULL, SW_HIDE);
#endif
我想知道是否有人知道为什么我的代码什么都不做,或者我可以使用一些解决方案。
也许试试 this one:
QProcess::execute( /*program*/, /*arguments*/ );
路径中有avrdude
吗?如果不是,您可以在执行该过程之前调用 setWorkingDirectory
或将其添加到路径中。为了检查它,打开命令行,cd
进入你的Qt
应用程序的二进制文件夹并输入命令:
avrdude -Cavrdude.conf.txt -v -v -v -v -patmega328p -arduino -PCOM7 -b115200 -D -Uflash:w:Blink.cpp.hex:i", 0
是运行吗?如果不是,你得到的错误是什么?
您也可以使用error
函数获取最后一个错误。