在窗口错误中使用QProcess启动进程:"Timers can only be used with threads started with QThread"
Start process with QProcess on windows error: "Timers can only be used with threads started with QThread"
我有一个最小的例子,我试图得到工作。最终目标是能够将一些信息传递给正在等待"cin"调用的程序。我猜这意味着与标准输入有关。
我正试图使用一些Qt对象来帮助我在这个阶段。虽然我没有使用任何其他Qt的东西。
我正在尝试给我错误的例子是:
#include <iostream>
#include <QtCore/QString>
#include <QtCore/QProcess>
#include <QtCore/QStringList>
int main() {
QProcess process;
QString prog = "test.exe";
// Starting "test.exe":
process.start(prog);
bool started = process.waitForStarted();
std::cout << started << std::endl;
// test.exe is waiting for cin, so give "2":
bool response = process.write("2n");
std::cout << response << std::endl;
}
下面是错误信息:
1
QObject::startTimer: Timers can only be used with threads started with QThread
1
QProcess: Destroyed while process ("test.exe") is still running.
在极少数情况下,你会有一个没有QApplication或QCoreApplication的qt应用程序。它们启动事件循环,需要计时器,事件,信号/槽。
控制台xml解析器可以是这种无事件的应用程序。
看看这里的一个最小的QtCoreApplication应用程序:我如何在c++中创建一个简单的Qt控制台应用程序?
在子类QWidget或QObject中启动进程。
相关文章:
- Problems with std::cin.fail()
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 这对"With a stackless coroutine, only the top-level routine may be suspended."意味着什么
- Boost.TEST with CLion: "Test framework quit unexpectedly"
- 避免碎片化的ClientHellos with OpenSSL (DTLS)
- Issues with Win32 ReadProcessMemory API
- Qt with WinAPI MouseProc
- [[maybe_unused]] with structured_binding?
- Issue with WriteProcessMemory
- OpenCV RTP-Stream with FFMPEG
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- std::adjacent_difference with std::chrono time_point
- DLL Made with CMake 使程序崩溃
- 如何修复输出日志中的"EnableInput can only be specified on a Pawn for its Controller"错误
- QtCreator with C 库中的链接器问题
- 在 c++11 模式下使用 QtConcurrent::run with move only 参数
- 平息海湾合作委员会的"only available with -std=c++XX or -std=gnu++XX"警告
- Directshow Preview Only 和 Capture & Preview with a Single Graph
- 在窗口错误中使用QProcess启动进程:"Timers can only be used with threads started with QThread"
- Android C++ framebuffer ioctl, only with root?