使用 QProcess 返回 Vim 搜索结果

问题描述 投票:0回答:1

我想写一个仪表板来显示Vim搜索结果。

假设结果如果没有找到,我会得到“E486:未找到模式。”,或者我会得到行号什么的。

但是我在一行中收到了这些消息:

警告:输出不是终端 警告:输入不是来自终端

void callVim::run() {
    QString kwd = "aaa";
    vimProcess->start("/usr/bin/vim", QStringList()<<MainWindow::filePath<<"+\\"+kwd);
    QString output = vimProcess->readAllStandardOutput();
    QString error = vimProcess->readAllStandardError();
}
c++ qt vim
1个回答
-2
投票

QProcess::start
是异步的。在读取进程输出之前,您必须使用一些 waitXXX 函数(例如
QProcess::waitForReadyRead
QProcess::waitForFinished
)。

© www.soinside.com 2019 - 2024. All rights reserved.