1. If you do not need to open the specified file, you can use the following code
Qdesktopservices::openurl (Qurl::fromlocalfile (File_path));
2. If you need to specify a file
Can call the Windows API ShellExecute () to complete
Specific as follows:
2.1 <mainwindow.h>
#include <windows.h>
#include <shellapi.h>
qtextcodec *codec;
2.2 <mainwindow.cpp>
codec = Qtextcodec::codecforname ("GB18030"); Windows uses GBK encoding by default, QT uses UTF-8 encoding by default and requires conversion
2.3 Call Explorer to open the file browser and make the file, format "Explorer/select, E:\Table_1.txt" must be a backslash, otherwise fail, I've been here a long time
and the QT default Qfileinfo::filepath () is a backslash, ie '/', so you have to do the code as follows
QString argsstr = "/select," +fileinfo.filepath (). Replace ("/", "\ \"); Replace file directory delimited form
Shellexecutea (NULL, "Open", "Explorer", Codec->fromunicode (ARGSSTR). Constdata (), Null,sw_ Showdefault);//convert UTF-8 to GBK and convert to const char* type