在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
我想知道是否有人知道为什么我的代码什么都不做,或者我可以使用的一些解决方案。
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
函数来获取最后一个错误
不妨试试这个:
QProcess::execute( /*program*/, /*arguments*/ );
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 父进程意外被子 cmd 杀死.exe运行 java jar 的进程 - WINDOWS 7 问题 - C++
- 使用管道从 STDIN 读取分叉进程时出现问题
- 在 Linux 中从单独的单线程进程生成多线程进程时出现问题
- 在 c++ 中等待一个子进程与另一个子进程时遇到问题
- 使用boost进程间库的phpexec共享内存和Cloudfoundry容器问题
- 从导致问题的java进程附加到外部c++进程
- 使用SetParent将窗口嵌入外部进程的各种问题
- 读取进程内存问题未更新
- C++创建进程 - 系统错误#2找不到文件 - 我的文件路径有什么问题?
- 从另一个进程访问STA对象时出现问题
- COM进程中DLL中的DllMain出现问题
- 打开带有DEBUG标志的进程的问题
- 创建读取面向互联网的套接字的守护进程有什么安全问题?
- Q执行带参数的exe时出现进程问题
- 枚举进程句柄,奇怪的问题
- Q进程::执行(“清除”)问题
- 在Qt中使用windows进程时的问题