久久久久久久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精品国产日韩91久久久久久 | 国产乱人乱偷精品视频 | 在线观看的av网站 | 久久久成人精品 | 中文字幕婷婷 | 黄色毛毛片 | 免费不卡视频 | 日韩av免费在线观看 | 免费三片在线观看网站v888 | 在线观看黄色小说 | 亚洲午夜18毛片在线看 | 天天天天天干 | 一区二区三区视频 | 欧美日韩精品一区 | 久久久久久网站 | 国产精品久久久一区二区三区 | 中文字幕+乱码+中文乱码91 | 免费成人毛片 | 久久综合影院 | 成人毛片在线观看 | 亚洲激情第一页 | 麻豆视频一区二区 | 欧美爱爱视频 | 亚洲成av | 一级肉体全黄裸片 | 日韩成人高清 | 中国毛片视频 | 久久久精品一区二区 | 99色综合 | 18视频在线观看 | 福利视频一区二区 | 欧美一区二区三区不卡 | 欧美日韩免费视频 | 四虎看片| 日韩高清在线 | 国产片一区二区 |