QT获取程序运行的路径

在工程中需要使用程序运行时使用的路径问题

/* 获取文件生成的目录 */
  QString path = QCoreApplication::applicationDirPath();

解释如下:

QString QCoreApplication::applicationFilePath()
Returns the file path of the application executable.
For example, if you have installed Qt in the /usr/local/qt directory, and you run the regexp example, this function will return “/usr/local/qt/examples/tools/regexp/regexp”.
Warning: On Linux, this function will try to get the path from the /proc file system. If that fails, it assumes that argv[0] contains the absolute file name of the executable. The function also assumes that the current directory has not been changed by the application.

你可能感兴趣的:(图形界面QT,C++)