Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Set a default UNC path for QFileDialog
Qt 6.12 LTS is out! See what's new in the release blog

Set a default UNC path for QFileDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.9k 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.
  • AzadshahrA Offline
    AzadshahrA Offline
    Azadshahr
    wrote on last edited by
    #1

    I wanted to open QFileDialog with a specific path like: //Machine/C$/Users/. I have implemented the following function but it doesn't work.

    void DownloadFM::on_pushButtonSource_clicked()
    {
        QFileDialog o_dialogSource;
        o_dialogSource.setDirectory(absolutePath);
        QString fileName = QFileDialog::getOpenFileName(this, "Choose File");
    
        if(fileName.isEmpty())
            return;
    
        ui->lineEditSource->setText(fileName);
    }
    
    JonBJ 1 Reply Last reply
    0
    • AzadshahrA Azadshahr

      I wanted to open QFileDialog with a specific path like: //Machine/C$/Users/. I have implemented the following function but it doesn't work.

      void DownloadFM::on_pushButtonSource_clicked()
      {
          QFileDialog o_dialogSource;
          o_dialogSource.setDirectory(absolutePath);
          QString fileName = QFileDialog::getOpenFileName(this, "Choose File");
      
          if(fileName.isEmpty())
              return;
      
          ui->lineEditSource->setText(fileName);
      }
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Azadshahr
      I am not sure Qt file dialogs/operations support UNCs.

      1 Reply Last reply
      0
      • AzadshahrA Offline
        AzadshahrA Offline
        Azadshahr
        wrote on last edited by
        #3

        So what should I do now?

        JonBJ 1 Reply Last reply
        0
        • AzadshahrA Azadshahr

          So what should I do now?

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

          @Azadshahr
          Before proceeding: It would be nice to see a qDebug() << absolutePath. I have done enough support in this forum to know that when questioners say something like " with a specific path like: //Machine/C$/Users/" it can turn out that is not actually what they are passing....

          Furthermore, how do I know whether your app is running with sufficient privilege to read \\Machine\C$, which is an administrative share? Have you tried other UNC shares, non-Administrative?

          Finally, all you have said is " following function but it doesn't work". What exactly does "doesn't work" mean? Where does the file dialog place you if the UNC is not accepted?

          1 Reply Last reply
          2
          • AzadshahrA Offline
            AzadshahrA Offline
            Azadshahr
            wrote on last edited by
            #5

            Sorry, I should describe it more. However, I have a program which is works with the file system pretty well. I can create file/directory, rename file/directory, delete file/directory, and so on but when I wanted to move a directory to another place with using QDir::rename, it returns false to me. I give to this function two-path i.e. //Machinex64/C$/Users/FolderSample1 and //Machinex64/C$/Users/FolderSample2. When this function executed, it can't move the directory. Also, I give to application administrative privilege.

            JonBJ mrjjM 2 Replies Last reply
            0
            • AzadshahrA Azadshahr

              Sorry, I should describe it more. However, I have a program which is works with the file system pretty well. I can create file/directory, rename file/directory, delete file/directory, and so on but when I wanted to move a directory to another place with using QDir::rename, it returns false to me. I give to this function two-path i.e. //Machinex64/C$/Users/FolderSample1 and //Machinex64/C$/Users/FolderSample2. When this function executed, it can't move the directory. Also, I give to application administrative privilege.

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

              @Azadshahr
              For my part, I cannot see any relation to whatever you are saying in your last post and setting a UNC path in a QFileDialog. If you have some application privilege issue you should deal with that separately from a UNC issue.

              1 Reply Last reply
              0
              • AzadshahrA Azadshahr

                Sorry, I should describe it more. However, I have a program which is works with the file system pretty well. I can create file/directory, rename file/directory, delete file/directory, and so on but when I wanted to move a directory to another place with using QDir::rename, it returns false to me. I give to this function two-path i.e. //Machinex64/C$/Users/FolderSample1 and //Machinex64/C$/Users/FolderSample2. When this function executed, it can't move the directory. Also, I give to application administrative privilege.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                So you can read/create files etc in //Machinex64/C$/Users/FolderSample2 ?
                its ONLY the QDir::rename that fails ?

                1 Reply Last reply
                0

                • Login

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