Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error 2 when use QFileDialog::getOpenFileName
Forum Updated to NodeBB v4.3 + New Features

Error 2 when use QFileDialog::getOpenFileName

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 313 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrew23
    wrote on last edited by
    #1

    When I use the QFileDialog::getOpenFileName I get a lot of the same error in the Application Output window

    connect( 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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which version of Qt are you using ?
      On which OS ?
      What does QDir::homePath return ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Which version of Qt are you using ?
        On which OS ?
        What does QDir::homePath return ?

        A Offline
        A Offline
        Andrew23
        wrote on last edited by
        #3

        @SGaist I'm using Qt 6.4.3 on Windows 10 and QDir::homePath return true

        JonBJ 1 Reply Last reply
        0
        • A Andrew23

          @SGaist I'm using Qt 6.4.3 on Windows 10 and QDir::homePath return true

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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) returns

          If the lpValue registry value does not exist, the function returns ERROR_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.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved