- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在我的应用程序中,我需要加载许 multimap 像。我真的会使用一个选项来选择最后打开的文件,所以我想知道最后选择的文件。文档说:
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
"/home",
tr("Images (*.png *.xpm *.jpg)"));
The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected.
所以我应该将最后打开的文件路径保存在某处,然后插入它而不是“/home”。但这是行不通的。在打开的文件对话框中,文件名被剥离到最后几个字符并且没有文件被选中。怎么了?是错误吗?
我当前的代码:
QString fileName = QFileDialog::getOpenFileName(this, "Select file",
lastUsedFile, "Image Files (*.png *.jpg *.jpg *.bmp);; JPEG(*.jpg *.jpeg);; PNG(*.png);; BMP(*.bmp)");
if (!fileName.isEmpty())
lastUsedFile = fileName;
我想要实现的是选择并滚动到文件。
最佳答案
它是QFileDialog::getOpenFileName()的第三个参数。然后您必须将其存储在 QSettings 中。
例如:
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open file"),
Settings.value(DEFAULT_DIR).toString(),
tr("Images (*.png *.xpm *.jpg)");
if (!fileName.isEmpty()) {
QDir curDir;
Settings.setValue(DEFAULT_DIR, curDir.absoluteFilePath(fileName));
}
关于c++ - getOpenFileName - 预选上次打开不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42898735/
之前看到一些类似的问题,想弄清楚。 在this article ,据说异步调用“没有线程”。 然而,in another one ,据说 Here, however, we’re running th
我为我公司的平板电脑(SAMSUNG Galaxy Tab Active2)开发了一个简单的软件,自上周五(2018 年 11 月 23 日)以来,它无法正常工作。我检查了该应用程序的所有功能,其中有
我正在使用 hadoop map-reduce 作业进行一些文本处理。我的工作已完成 99.2%,并停留在上一个 map 工作上。 map 输出的最后几行如下所示。上次发生此问题时,我尝试打印出从 m
上次 Ubuntu 更新后有人对 Docker 有疑问吗?我有 2 个由 docker-compose 在 ubuntu18.04 中运行的项目。两个项目都运行良好,但在 *.yml 中进行 0 次更
SQL Developer 在表中显示公共(public)同义词的创建和上次 DDL 时间: CREATED 15-AUG-09 LAST_DDL_TIME 15-AUG-09 O
我正在使用带有以下插件的 mavenized 库项目: com.jayway.maven.plugins.android.generation2
我正在使用 Jssor Slider 作为轮播。在 Google Chrome 上次更新到版本 45.0.2454.85 之前,它一直运行良好。想法是它不显示图像。目前,它们位于标签中,可在 Safa
我是一名优秀的程序员,十分优秀!