Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved I want to get directory address

    General and Desktop
    3
    7
    911
    Loading More Posts
    • 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
      Armin last edited by

      Hi
      I want to get directory address ( like g:\document\armin\qt ) by getExistingDirectoryUrl.
      I don't get error but i don't have any address from directory i did choose.

      void MainWindow::on_toolButton_clicked()
      {
        urll = QFileDialog::getExistingDirectoryUrl();
      }
      
      void MainWindow::on_pushButton_3_clicked()
      {
          ui->label_14->text() = urll.toString();
      
      }
      
      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi
        You must tell more about what is not working.
        if I run your code it does give me path
        Like

        "file:///C:/Windows/debug"
        
        1 Reply Last reply Reply Quote 2
        • A
          Armin last edited by

          @mrjj Thanks
          I want to save file in directory which selected by getExistingDirectoryUrl() function .

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @Armin last edited by

            @Armin And what is the problem?Is this urll the same in both slots? Is on_toolButton_clicked() executed before on_pushButton_3_clicked() ? How do you store the file?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • A
              Armin last edited by

              @jsulm Thank you
              For example : you want to determine which where your file be save , so you should determine a directory url , for instance : c:/document/arminfolder
              So i use a button which open my directory in windows. but i can't save directory in variable

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @Armin last edited by

                @Armin Are you aware that this is wrong?

                ui->label_14->text() = urll.toString();
                

                If you want to set text in a label then you need to do:

                ui->label_14->setText(urll.toString());
                

                It is all in the documentation.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 3
                • A
                  Armin last edited by

                  @jsulm oh sorry , i forget
                  You right and my problem solve
                  Thanks

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post