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
Forum Updated to NodeBB v4.3 + New Features

QDir make path does not create an empty folder

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 620 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 25 Aug 2020, 06:45 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.

    J 1 Reply Last reply 25 Aug 2020, 06:48
    0
    • G GunkutA
      25 Aug 2020, 07:00

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

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 25 Aug 2020, 07:15 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
        25 Aug 2020, 06:45

        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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 25 Aug 2020, 06:48 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 25 Aug 2020, 07:00
        2
        • J jsulm
          25 Aug 2020, 06:48

          @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 25 Aug 2020, 07:00 last edited by
          #3

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

          M 1 Reply Last reply 25 Aug 2020, 07:15
          0
          • G GunkutA
            25 Aug 2020, 07:00

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

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 25 Aug 2020, 07:15 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

            1/4

            25 Aug 2020, 06:45

            • Login

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