QT自带弹出对话框选取文件并返回文件路径
- 标题在
.c
文件的开头或者对应的.h
文件开头添加
#include <QFileDialog>
#include <QFile>
- 打开对话框选取文件并返回文件路径
QString filePath = QFileDialog::getOpenFileName();
//返回的路径字符串是以‘/’隔开
- 获取文件名(不带文件后缀)
QFileInfo base(filePath);
QString baseName = base.baseName();
C++
- c++成员函数后面跟“:”表示的是赋值,这是c++的特性
My_feature (const Point_range& range,
double xmin, double xmax, double ymin, double ymax)
: range (range), xmin(xmin), xmax(xmax), ymin(ymin), ymax(ymax)
{}
//例如
My_feature (const Point_range& range,
double xmin, double xmax, double ymin, double ymax)
{
range = range;
...
ymax = ymax;
}
c++构造函数后面跟“:”也表示赋值
- 遍历
vector
for(auto &it : num) {
cout << ++it << endl;
}
利用
it
遍历并获得num容器中的每一个值,但是it
可以影响到num
容器中的元素
对it
赋值就是对相应的num
容器元素赋值