找回密码
 立即注册
收起左侧

求助,使用getSaveFileName 在debug下报异常

3
回复
8256
查看
[复制链接]
累计签到:1 天
连续签到:1 天
来源: 2017-6-13 11:11:07 显示全部楼层 |阅读模式
1Qter豆
本帖最后由 11hours 于 2017-6-13 11:17 编辑

很简单的代码,基于MAINWINDOW程序,运行QFileDialog::getSaveFileName就报异常
  1. #include "mainwindow.h"
  2. #include <QFileDialog>
  3. #include <QString>
  4. MainWindow::MainWindow(QWidget *parent)
  5.     : QMainWindow(parent)
  6. {
  7.     QString xlsFile = QFileDialog::getSaveFileName(this, QString("111"),
  8.     QString("E:/GoogleDrive/Projects/QT/FRACTURE/test.xlsx"),
  9.     QString("excel(*.xls *.xlsx)"),
  10.     &QString("excel(*.xls *.xlsx)"), QFileDialog::HideNameFilterDetails);
  11. }
复制代码
异常为

debug下这段代码放到任何位置都会报这样的异常。只有将Options options = Options() 设为DontUseNativeDialog 才不会报。
release下没有报异常。

我的系统为windows 8.1 64位


百度没有相关问题,google虽然有但情形不一样,怎么办啊。

附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册
回复

使用道具 举报

累计签到:1 天
连续签到:1 天
2017-6-13 12:35:27 显示全部楼层
查到了一篇关于code: 0x8001010e的解释
The error 0x8001010E is RPC_E_WRONG_THREAD "The application called an interface that was marshalled for a different thread.".
You are breaking COM apartment rules and you are attempting to use an interface pointer on a thread that does not belong to apartment the pointer is valid for. To pass interface pointer to another apartment use marshaling.
就算知道原因可怎么改啊
回复

使用道具 举报

累计签到:742 天
连续签到:1 天
2017-6-13 14:09:11 显示全部楼层
是路径中文导致的嘛 ?
回复

使用道具 举报

累计签到:1 天
连续签到:1 天
2017-6-14 12:33:33 显示全部楼层
Since 发表于 2017-6-13 14:09
是路径中文导致的嘛 ?

不是,根据code: 0x8001010e的解释,因为qt在主线程外调用了windows的组件就会报这个错误。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了