I want to get directory address



  • 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();
    
    }
    

  • Qt Champions 2017

    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"
    


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


  • Moderators

    @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?



  • @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


  • Moderators

    @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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.