There are a few small details that need to be recorded here in the afternoon writing program.
?
| 123456789101112131415 |
QProcess *process = new QProcess(this); QFileInfo fileinfo(appUrl); QString appPath = QApplication::applicationDirPath()+SAVEDIR+"/"+fileinfo.fileName(); bool res = process->startDetached(appPath,QStringList()); if (res) { accept(); } else { MyHelper::ShowMessageBoxError("下载完成但自动升级失败,请手工安装升级包!"); QDesktopServices::openUrl(QUrl::fromLocalFile(QApplication::applicationDirPath()+SAVEDIR)); reject(); } |
This was written in the original code:
process->startDetached(appPath);
There is no problem with the test environment, but the production environment cannot invoke external programs and eventually discovers that the file path of the production environment
C:\Program Files (x86)\...With a space, causing the call to fail, so Google then tries to
process->startDetached(appPath,QStringList());
Problem solved.
QDesktopServices::openUrl(QUrl(QApplication::applicationDirPath()+SAVEDIR));
The same problem exists in this place, and if you use qurl::fromlocalfile for processing, you can open the folder normally:
QDesktopServices::openUrl(QUrl::fromLocalFile(QApplication::applicationDirPath()+SAVEDIR));
In addition, there is a problem with this code-Independent: QT Call VC write dynamic Library, VC need to use C way output function, otherwise MinGW32 compile process will error, namely:
Example VC DLL header file:
?
| 12345678910111213 |
#ifndef cdoublereaderdll #ifdef cdoublereaderdll_exports #define cdoublereaderdll extern "C" __declspec (dllexport) #else #define cdoublereaderdll extern" C "__declspec (dllimport) #endif #endif   # define buffersize # define ReadTimeout //open serial port Cdoublereaderdll bool _stdcall Rd_open ( int iport,unsigned long ibaudrate); ... |
Examples of calls in QT:
?
| 1234 |
extern"C"{ #include "drivers/CdoubleReaderDll.h"} |
Reprint Please specify: Under the Sycamore Tree»QT open External programs and folders to pay attention to the details
http://www.pfeng.org/archives/808
QT Open external programs and folders need to pay attention to the details (note qprocess space problems, and open local files, need to Qurl::fromlocalfile to do)