Error 2 when use QFileDialog::getOpenFileName
-
When I use the
QFileDialog::getOpenFileName
I get a lot of the same error in the Application Output windowconnect( ui->LoadFilePushButton, &QPushButton::clicked, this, &MyQDialog::LoadFile ); void MyQDialog::LoadFile() { QString fileName = QFileDialog::getOpenFileName( this, tr( "Open File" ), QDir::homePath(), tr( "Files (*.csv)" ) ); [...] }
When I click the button I get in the output
Error 2 in function StorageSystem::Registry::ATypeIOHandlerBase<4,0>::Read: RegGetValueW raised error 2: Impossibile trovare il file specificato. Error 2 in function StorageSystem::Registry::ATypeIOHandlerBase<4,0>::Read: RegGetValueW raised error 2: Impossibile trovare il file specificato. Error 2 in function StorageSystem::Registry::ATypeIOHandlerBase<4,0>::Read: RegGetValueW raised error 2: Impossibile trovare il file specificato. Error 2 in function StorageSystem::Registry::ATypeIOHandlerBase<4,0>::Read: RegGetValueW raised error 2: Impossibile trovare il file specificato. [and so on...]
Why?
-
Hi,
Which version of Qt are you using ?
On which OS ?
What doesQDir::homePath
return ? -
@Andrew23 said in Error 2 when use QFileDialog::getOpenFileName:
QDir::homePath return true
It's not a boolean. We want to know what your call to
QDir::homePath()
returns, to make sure it's not empty. And assuming it's not empty, can you confirm that the directory exists?It looks to me as though a Windows registry value cannot be found. Windows system call
RegGetValueW()
(https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluew) returnsIf the
lpValue
registry value does not exist, the function returnsERROR_FILE_NOT_FOUND
.and it would not surprise me if it returns same if
lpSubKey
cannot be found too.Don't worry too much about the use of the word "file" here, it does not really mean an actual file.
Why it is happening, and whether it is intended or matters, I do not know.