当前位置:网站首页>qt中获取当前目录
qt中获取当前目录
2022-07-28 05:25:00 【小土同学!】
前言
qt中获取当前目录需要注意几个坑,以linux环境为例
当前路径有两种可能
- 一是可执行程序所在目录
- 二是执行命令时所在的目录,如我在/目录下在命令行执行/usr/local/ls命令,这时候的目录就是/目录
先上代码:
QDir::currentPath() //执行命令时所在的目录,如我在/目录下在命令行执行/usr/local/ls命令,这时候的目录就是/目录
QCoreApplication::applicationDirPath() //可执行程序所在目录
案例:
#include <QDir>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug()<<"currentPath"<<QDir::currentPath();
qDebug()<<"programePath"<<QCoreApplication::applicationDirPath();
}
然后在命令行执行测试:
码字不易,如果这篇博客对你有帮助,麻烦点赞收藏,非常感谢!有不对的地方,可以评论区交流。
边栏推荐
- IMS-FACNN(Improved Multi-Scale Convolution Neural Network integrated with a Feature Attention Mecha
- PyTorch 学习笔记 1 —— Quick Start
- mysql join技巧
- [yolov5] environment construction: win11 + mx450
- Communication between DSP and FPGA
- Precautions for EMI design of switching power supply circuit in layout process
- 当mysql表从压缩表变成普通表会发生什么
- An example of bill printing
- Cronbach’s α?KMO系数?因子载荷?史上最易懂的问卷信效度分析教程!!!(SPSS和AMOS)
- Bag of Tricks训练卷积网络的技巧
猜你喜欢

Vs code basic configuration and beautification

Pytorch learning note 4 - automatic calculation of gradient descent autograd

【YOLOv5】环境搭建:Win11 + mx450

Selection of PLC

Synopsys Multivoltage Flow

Cronbach’s α?KMO系数?因子载荷?史上最易懂的问卷信效度分析教程!!!(SPSS和AMOS)

clock tree分析实例

CLIP Learning Transferable Visual Models From Natural Language Supervision

Briefly introduce EMD decomposition, Hilbert transform and spectral method

T-sne dimension reduction visualization
随机推荐
Selection of PLC
Measure computer battery capacity
How can fluke dsx2-5000 and dsx2-8000 modules find the calibration expiration date?
Fluke dtx-1800 and its accessories dtx-cha002 channel adapter channel replacement RJ45 socket notes
初学者进行传感器选型
权重衰减 weight decay
Fluke fluke aircheck WiFi tester cannot configure file--- Ultimate solution experience
雷达成像 Matlab 仿真 4 —— 距离分辨率分析
Talking about fluke optical cable certification? What is CFP? What is OFP?
The short jumper dsx-8000 test is normal, but the dsx-5000 test has no length display?
Led selection - hardware learning notes 3
多个ics日历合并成单个ics日历
Matlab 信号处理
USB network native driver for esxi updated to support esxi7.0.1
Efficient Net_V2
Design and analysis of contactor coil control circuit
WebService error maximum message size quota for incoming messages (65536) has been exceeded
Pytorch learning notes 3 - datasets & dataloaders & transforms
Ship detection in SAR image based on yolov5
ClickHouse 中的公共表表达式CTE