久久久久久久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 ()?環形?)
主站蜘蛛池模板: 99久久精品视频免费 | 国产午夜视频 | 欧美亚洲国产成人 | 亚洲精品一区二区在线 | 午夜精品一区二区三区在线观看 | 国产午夜精品视频 | 日韩成人av在线 | 日本xx视频免费观看 | 国产三级国产精品 | 欧美精品在线免费 | 男女免费视频网站 | 久久成人一区 | 久久精品色视频 | 成人av电影在线 | 国产精品视频播放 | 亚洲第一av | 亚洲精品久久久一区二区三区 | 亚洲视频二区 | 欧美日韩在线视频观看 | 久久成人国产精品 | 国产丝袜一区二区三区免费视频 | 一区精品视频在线观看 | 日日操视频 | 美女福利视频网站 | 久久99精品久久久久久国产越南 | 黄色国产 | 亚洲在线免费观看 | 亚洲另类视频 | 亚洲国产区 | 九九精品在线 | 中文字幕国产精品视频 | 成人午夜免费福利视频 | 久久亚洲春色中文字幕久久久 | 在线欧美小视频 | 亚洲欧美视频一区二区 | 国产在线二区 | 日本一区二区三区四区 | 喷水毛片| 中文字幕1区 | 天堂中文av | 秋霞在线一区二区 |