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 make path does not create an empty folder

QDir make path does not create an empty folder

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 821 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.
  • G Offline
    G Offline
    GunkutA
    wrote on last edited by
    #1

    Hello I am trying to create an empty folder. However, it does not create any folder. When I call the program first time it printed the qDebug(), but after that it does not enter to the if statement:

            QString path =QDir::currentPath();
           if(!QDir().exists(path))
           {
               QDir().mkpath(path);
               qDebug()<<"Created";
    
           }
    

    When I enter some path to path manually, it always enters the if statement for the first call after that it never enters that. So I believe it creates something. But I cannot see any folder that has been created.

    jsulmJ 1 Reply Last reply
    0
    • G GunkutA

      @jsulm I should have used mkdir() for creating a folder. I see.

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

      @GunkutA
      Hi
      mkpath makes whole path if needed - so it can also be used to create a folder.
      but when you use the path currentPath();
      and check if that exists, it most likely alwyas will be there so
      i guess why you though it didnt work.

      1 Reply Last reply
      4
      • G GunkutA

        Hello I am trying to create an empty folder. However, it does not create any folder. When I call the program first time it printed the qDebug(), but after that it does not enter to the if statement:

                QString path =QDir::currentPath();
               if(!QDir().exists(path))
               {
                   QDir().mkpath(path);
                   qDebug()<<"Created";
        
               }
        

        When I enter some path to path manually, it always enters the if statement for the first call after that it never enters that. So I believe it creates something. But I cannot see any folder that has been created.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #2

        @GunkutA said in QDir make path does not create an empty folder:

        QString path =QDir::currentPath();

        You're trying to create existing path (the current path) - how is this going to work?!

        "But I cannot see any folder that has been created." - how do you check whether the path was created (on which OS, using what tool?)?

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

        G 1 Reply Last reply
        2
        • jsulmJ jsulm

          @GunkutA said in QDir make path does not create an empty folder:

          QString path =QDir::currentPath();

          You're trying to create existing path (the current path) - how is this going to work?!

          "But I cannot see any folder that has been created." - how do you check whether the path was created (on which OS, using what tool?)?

          G Offline
          G Offline
          GunkutA
          wrote on last edited by
          #3

          @jsulm I should have used mkdir() for creating a folder. I see.

          mrjjM 1 Reply Last reply
          0
          • G GunkutA

            @jsulm I should have used mkdir() for creating a folder. I see.

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

            @GunkutA
            Hi
            mkpath makes whole path if needed - so it can also be used to create a folder.
            but when you use the path currentPath();
            and check if that exists, it most likely alwyas will be there so
            i guess why you though it didnt work.

            1 Reply Last reply
            4

            • Login

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