16,211
社区成员
发帖
与我相关
我的任务
分享
bool QFile::link ( const QString & linkName )
Creates a link named linkName that points to the file currently specified by fileName(). What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Returns true if successful; otherwise returns false.
This function will not overwrite an already existing entity in the file system; in this case, link() will return false and set error() to return RenameError.
Note: To create a valid link on Windows, linkName must have a .lnk file extension.
Note: Symbian filesystem does not support links.
See also setFileName().
bool QFile::link ( const QString & fileName, const QString & linkName ) [static]
This is an overloaded function.
Creates a link named linkName that points to the file fileName. What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Returns true if successful; otherwise returns false.
See also link().
补充:创建文件夹的快捷方式到指定路径(下例为桌面)
//注意第一个参数指定文件夹的路径,第二个参数指定快捷方式放置的路径以及新名称,记得一定要加.lnk后缀
bool ret = QFile::link(QString("./Serialization"),QString("C:/Users/Administrator/Desktop/Serialization.lnk"));
if(!ret){
qDebug("error");
}
亲测,成功!