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. QDir mkdir and switch to newly made directory?
Qt 6.11 is out! See what's new in the release blog

QDir mkdir and switch to newly made directory?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 628 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.
  • C Offline
    C Offline
    Calicoder
    wrote on last edited by
    #1

    Good day fellow QT'ers, wondering if anyone has run into this issue yet? I have the following code:

    ui->comboBox->addItem("Item01");
    QDir dir("C:/Users/Calicoder/QTdocs");
    dir.mkdir(ui->comboBox->currentText());
    dir.setCurrent(ui->comboBox->currentText()); <------ doesn't switch to the newly created folder
    

    That creates the C:/Users/Calicoder/QTdocs/Item01 folder perfectly, how would I go to switching into that directory now as the last line doesn't work? Checking the dir.path() always returns C:/Users/Calicoder/QTdocs

    Appreciate the help, thanks!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Hi,
      Try:
      dir.cd(ui->comboBox->currentText());

      C 1 Reply Last reply
      2
      • M mpergand

        Hi,
        Try:
        dir.cd(ui->comboBox->currentText());

        C Offline
        C Offline
        Calicoder
        wrote on last edited by
        #3

        @mpergand Beautiful that worked, thanks. Any idea why the dir.path() doesn't update to show the new path? It's still stuck at C:/Users/Calicoder/QTdocs

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Calicoder
          wrote on last edited by
          #4

          Added a dir.setCurrent(ui->comboBox->currentText()); after the dir.cd() and it works now with dir.path();

          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 Extensions
          • Unsolved