How to fix error code code: 0x8001010e when using getSaveFileName
-
@joeQ Sorry my English is so poor. I mean I wanna make a short post.
and yes, i got same error code of 0x8001010e by using slot-signal.@11hours Hi, friend,
void MainWindow::SaveFile() { QString xlsFile = QFileDialog::getSaveFileName(this, QString("111"), QString("E:/GoogleDrive/Projects/QT/FRACTURE/test.xlsx"), QString("excel(*.xls *.xlsx)"), &QString("excel(*.xls *.xlsx)"), QFileDialog::ShowDirsOnly); ///< why you used the & ??? }
-
@joeQ Sorry my English is so poor. I mean I wanna make a short post.
and yes, i got same error code of 0x8001010e by using slot-signal.Hi, friend, i am so worry not to watch you code careful. the below code is ok in my Mac OS.
I think you used wrong about
selectedFilter
.#include "widget.h" #include <QFileDialog> #include <QTimer> #include <QDebug> Widget::Widget(QWidget *parent) : QWidget(parent) { QTimer::singleShot(1000,this,&Widget::StSaveFile); } Widget::~Widget() { } void Widget::StSaveFile() { QString filter = QString("excel(*.xls *.xlsx)"); QString selFile = QFileDialog::getSaveFileName(this, QString("111"), QString("E:/GoogleDrive/Projects/QT/FRACTURE/test.xlsx"), QString("excel(*.xls *.xlsx)"), &filter, QFileDialog::ShowDirsOnly); qDebug() << selFile; }
-
Hi, friend, i am so worry not to watch you code careful. the below code is ok in my Mac OS.
I think you used wrong about
selectedFilter
.#include "widget.h" #include <QFileDialog> #include <QTimer> #include <QDebug> Widget::Widget(QWidget *parent) : QWidget(parent) { QTimer::singleShot(1000,this,&Widget::StSaveFile); } Widget::~Widget() { } void Widget::StSaveFile() { QString filter = QString("excel(*.xls *.xlsx)"); QString selFile = QFileDialog::getSaveFileName(this, QString("111"), QString("E:/GoogleDrive/Projects/QT/FRACTURE/test.xlsx"), QString("excel(*.xls *.xlsx)"), &filter, QFileDialog::ShowDirsOnly); qDebug() << selFile; }
-
@joeQ the code can get the correct file name.
qDebug output the selFile : "E:/GoogleDrive/Projects/QT/FRACTURE/test.xlsx".
but the it still throw the error code. -
@11hours ok, let's test again.
test the below code.
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"",tr("Images (*.png *.xpm *.jpg)")); qDebug()<< fileName
-
@11hours ok, let's test again.
test the below code.
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"",tr("Images (*.png *.xpm *.jpg)")); qDebug()<< fileName
-
@joeQ I think it is because the method QT uses to call WINDOWS native dialog is not safe, so WINDOWS throw the error, right?
From these test, i am sure this error is not your fault.
did you used
DontUseNativeDialog option
, you can test it.QFileDialog::DontUseNativeDialog Do not use the native file dialog. By default, the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro, or the platform does not have a native dialog of the type that you require.
test code snippet
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"",tr("Images (*.png *.xpm *.jpg)"),0,QFileDialog::DontUseNativeDialog); qDebug()<< fileName ``
-
From these test, i am sure this error is not your fault.
did you used
DontUseNativeDialog option
, you can test it.QFileDialog::DontUseNativeDialog Do not use the native file dialog. By default, the native file dialog is used unless you use a subclass of QFileDialog that contains the Q_OBJECT macro, or the platform does not have a native dialog of the type that you require.
test code snippet
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"",tr("Images (*.png *.xpm *.jpg)"),0,QFileDialog::DontUseNativeDialog); qDebug()<< fileName ``
-
@joeQ yes, like I said before, if i use DontUseNativeDialog, there will be no error reported.
From this, I think i got into problem same with you before. ok, you can use one macro in your program, use the windows native file dialog under release version, not use native file dialog under debug version.
void MainWindow::StOpenFile() { /** ... */ #ifdef DONT_USE_NATIVE_DIALOG QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE), 0, QFileDialog::DontUseNativeDialog); #else QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE)); #endif /** ... */ }
-
From this, I think i got into problem same with you before. ok, you can use one macro in your program, use the windows native file dialog under release version, not use native file dialog under debug version.
void MainWindow::StOpenFile() { /** ... */ #ifdef DONT_USE_NATIVE_DIALOG QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE), 0, QFileDialog::DontUseNativeDialog); #else QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE)); #endif /** ... */ }
-
-
From this, I think i got into problem same with you before. ok, you can use one macro in your program, use the windows native file dialog under release version, not use native file dialog under debug version.
void MainWindow::StOpenFile() { /** ... */ #ifdef DONT_USE_NATIVE_DIALOG QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE), 0, QFileDialog::DontUseNativeDialog); #else QStringList ltFilePath = QFileDialog::getOpenFileNames(this, tr("Open files"), defaultDir, QString(STR_OPEN_FILE)); #endif /** ... */ }
thank you @joeQ.
I'm sure now, the error also happens under release version, cause I tried using VS to compile, and it reported the same error under release version.
I don't know why QT does not report it.
I decide ignore the error temporarily.
thank you guys! -
although this problem is not solved yet, it seems like another issue in COM technology. I guess, in WINDOWS system, qFileDialog calls FileDialog in WINDOWS API.
-
@11hours did you move your programer to another computer to test it ? win7? or win10? or 64bit Qt etc.
-