我有以下函数调用:

sparseAct =new QAction(QIcon(":Icons/icons/sparse.jpg"),tr("Sparse Reconstruction"),this);

connect(sparseAct, SIGNAL(triggered()),this, SLOT(sparsereconstruction()));




void UAVgeoreferencer::sparsereconstruction(){

ShellExecute(NULL, L"open", L"C:\\WINDOWS\\system32\\cmd.exe", L"/C C:\\Images\\sparseRecon64.bat", L"C:\\Images\\", SW_SHOWNORMAL);

}


当我这样做时,我得到如下错误:


  uavgeoreferencer.obj:-1:错误:LNK2019:无法解析的外部符号
  函数“私有:无效__cdecl UAVgeoreferencer :: sparsereconstruction(void)”中引用的__imp_ShellExecuteW
  (?sparsereconstruction @ UAVgeoreferencer @@ AEAAXXZ)


谁能告诉我问题出在哪里,如何解决?

最佳答案

您可以将QProcess用于此目的,因为它继承了QObjectQIODevice,您拥有在可能正在使用的其他Qt对象之间传递数据所需的一切,而不必这样做。您始终可以创建自己的对象,这些对象继承自QObject,然后实现信号和插槽机制,但是QProcess将使生活变得更轻松,因为它已经具有访问shell所需的一切。但是,您面临的问题与链接器有关,并且与信号和插槽机制无关。

关于c++ - 如何使用Qt connect函数调用Shell Execute?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29511620/

10-13 08:33