久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

獲取 Qt 應用程序中的當前工作目錄

Get current working directory in a Qt application(獲取 Qt 應用程序中的當前工作目錄)
本文介紹了獲取 Qt 應用程序中的當前工作目錄的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Qt 庫用 C++ 編寫程序.我的主 bin 目錄中有一個指向可執行文件的符號鏈接.我希望我的程序的當前工作目錄是我的終端所在的目錄(即 pwd 命令的結果).我看到了 QDir::currentPath() 函數,但它返回了二進制文件所在的目錄.

I'm writing a program in C++ using the Qt library. There is a symbolic link in my home bin directory to the executable. I would like the current working directory of my program to be the directory in which I am with my terminal (ie. the result of the pwd command). I saw the QDir::currentPath() function, but it gives back the directory where the binary is.

如何找到我當前的工作目錄?

How can I find my current working directory?

推薦答案

感謝 RedX 和 Kaz 的回答.我不明白為什么我會給出exe的路徑.我找到了另一種方法:

Thank you RedX and Kaz for your answers. I don't get why by me it gives the path of the exe. I found an other way to do it :

QString pwd("");
char * PWD;
PWD = getenv ("PWD");
pwd.append(PWD);
cout << "Working directory : " << pwd << flush;

它不如單行優雅......但它對我有用.

It is less elegant than a single line... but it works for me.

這篇關于獲取 Qt 應用程序中的當前工作目錄的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 美女天天操 | 日韩在线免费 | 色偷偷噜噜噜亚洲男人 | 欧美日韩国产一区二区三区 | 欧美激情五月 | 日本a∨精品中文字幕在线 亚洲91视频 | 国产一区二区黑人欧美xxxx | 好姑娘高清在线观看电影 | 欧美日韩亚洲国产 | 美女视频一区 | 久草福利 | 不卡欧美| 国产99视频精品免视看9 | 国产1区2区 | 人人九九精| 日韩不卡一区二区 | 欧美成人免费在线视频 | 久久综合av | 欧美成年黄网站色视频 | 老牛影视av一区二区在线观看 | 激情 婷婷 | 国产成人一区 | 国产精品2 | 91在线电影| 国产精品1区 | 日韩久久中文字幕 | 久热中文字幕 | 久久久亚洲一区 | 97国产精品视频人人做人人爱 | 午夜在线电影网 | 日韩在线免费电影 | 久久久九九| 亚洲+变态+欧美+另类+精品 | 欧美男人天堂 | 色视频网站免费 | 欧美午夜一区二区三区免费大片 | 精品亚洲一区二区三区 | 天堂视频中文在线 | 色橹橹欧美在线观看视频高清 | 在线中文字幕第一页 | av天天干|