c++ - 将 QProcess 与包含执行文件路径的字符串一起使用

标签 c++ qt

我正在使用 Qt。 谁能告诉我如何在 QProcess 中使用字符串? 更清楚地说,我正在制作一个图像转换器,我在其中使用 QFileDialog 将 png 文件的目标文件路径转换为字符串。 现在我有一个 exe 文件,它可以完成 png 到 jpeg 的所有转换,我需要做这样的事情:

convertor.exe  path/to/png/file  path/for/storing/converted/output

我如何在 Qt 中做到这一点?

QProcess conv;
conv.start("C:/converter.exe" ??) what to do here?

最佳答案

您可以将参数作为 QStringList 提供给进程:

QStringList args;
args << "path/to/png/file" << "path/for/storing/converted/output";
QProcess conv;
conv.start("C:/converter.exe", args);

关于c++ - 将 QProcess 与包含执行文件路径的字符串一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11764553/

相关文章:

c++ - 在此范围内未声明“checkCudaErrors”

c++ - C++11 的垃圾收集 ABI 有实际用途吗?

c++ - OpenCV 在轮廓中获取点

c++ - 是否可以将 int(enum) 映射到类型

multithreading - 如何检查事件循环是否有线程外的挂起事件?

c++ - Qt:正确存储自定义小部件的图像资源

c++ - 在c plus plus中重新定义类错误

multithreading - QThread中的QTcpSocket

c++ - 替换方法改变 QByteArray 的大小

qt - 读取文本文件到 QStringList