当前位置:网站首页>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();
}
然后在命令行执行测试:
码字不易,如果这篇博客对你有帮助,麻烦点赞收藏,非常感谢!有不对的地方,可以评论区交流。
边栏推荐
- Introduction to Perl (IX) quotation
- Pycharm2019 set editor theme and default code
- Perl introductory learning (VIII) subroutine
- Low power design isolation cell
- 基于 YOLOV5 的 SAR 图像舰船检测
- USB network native driver for esxi updated to support esxi7.0.1
- 听说你也在实习|当我采访了几个大三实习生之后。
- Monitor the CPU temperature of raspberry pie 4B installed with esxi on ARM
- Pytorch learning notes 2 - about tensor
- EfficientNET_V1
猜你喜欢

Weight decay

Install visual studio 2019 steps and vs2019 offline installation package on win7

雷达成像 Matlab 仿真 1 —— LFM信号及其频谱

ICC2(一)Preparing the Design

PyTorch 学习笔记 3 —— DATASETS & DATALOADERS & TRANSFORMS

Cronbach’s α? Kmo coefficient? Factor load? The most understandable course of questionnaire reliability and validity analysis in history!!! (SPSS and AMOS)

MAE 掩码自编码是可扩展的学习

权重衰减 weight decay

Beta distribution (probability of probability)

Design and analysis of contactor coil control circuit
随机推荐
Cautious speculation about fusion on Apple silicon
Selection of PLC
Briefly introduce EMD decomposition, Hilbert transform and spectral method
VAN(DWConv+DWDilationConv+PWConv)
Graduation thesis | how to write literature review
VAN(DWConv+DWDilationConv+PWConv)
Bert bidirectional encoder based on transformer
Electric fast burst (EFT) design - EMC series hardware design notes 4
Agilent Agilent e5071 test impedance and attenuation are normal, except crosstalk ng--- Repair plan
Matlab simulation of radar imaging 2 - pulse compression and windowing
Fluke dtx-sfm2 single mode module of a company in Hangzhou - repair case
What about the insufficient memory of Clickhouse aggregation? Then improve the polymerization performance
Learning notes of hardware circuit design 1 -- temperature rise design
PT 基于Multi Voltage的Physical Aware
Monitor the CPU temperature of raspberry pie 4B installed with esxi on ARM
Ship detection in SAR image based on yolov5
clickhouse建宽表多少列最合适?
Perl入门学习(九)引用
The short jumper dsx-8000 test is normal, but the dsx-5000 test has no length display?
Install visual studio 2019 steps and vs2019 offline installation package on win7