我已经写了一个程序,它从用户指定的HTML网站去除标签。我知道创建一个图形用户界面程序,以使用户可以输入URL。Qt和Linux管道
我有下面的代码打开一个管道打开我制作的可执行文件,它处理来自QT程序的输入。
QString stringURL = ui->lineEdit->text();
const char* result;
ui->labelError->clear();
if(stringURL.isEmpty() || stringURL.isNull()) {
ui->labelError->setText("You have not entered a URL.");
stringURL.clear();
return;
}
std::string cppString = stringURL.toStdString();
const char* cString = cppString.c_str();
FILE *fid;
fid = popen("htmlstrip", "w"); //Note that this application is in the PATH
fprintf(fid, "%s\n", cString); //Send URL
pclose(fid);
但是,上面的代码只允许我写入管道。任何人都可以告诉我,如何让Qt程序将输入发送到可执行文件,然后在可执行文件完成处理后接收输出并将其放入Qt程序的文本框/文本区中?
+0
嗯......打开它“rw”并从管道读取? –
2012-03-13 14:40:12