Results 1 to 3 of 3

Thread: QDir spawning dir when not existing.

  1. #1
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QDir spawning dir when not existing.

    It sounds real easy, and as the Doc states it should work like this, but all I get is "unable to spawn"
    Qt Code:
    1. void blah(const QString &basedir){
    2. QDir dir(_basedir);
    3. if (!dir.exists()){
    4. qDebug() << "Dir " << _basedir << " does NOT exists";
    5. if (dir.mkpath(_basedir)){
    6. qDebug() << "Spawned base dir " << _basedir;
    7. }
    8. else{
    9. qDebug() << "Unable to spawn base dir " << _basedir;
    10.  
    11. return;
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    Note: _basedir may be absolute or relative

    may somone please point me to my mistake, I don't really see any.

    I allready read the doc twice, but I don't see any hint about this..

    thanks for any reply

  2. #2
    Join Date
    Sep 2009
    Posts
    72
    Thanked 10 Times in 10 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: QDir spawning dir when not existing.

    Hi


    I tried your code on my win Xp machine with 4.6.0 and it works fine for absolute as well as relative path however i had to change
    #
    void blah(const QString &basedir){
    to _basedir.
    That may not be the problem or may be it is ? can you check if you already have this _basedir variable globally declare with some different values ?
    i am assuming that your function parameter should be _basedir. correct me if i m wrong.

  3. #3
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDir spawning dir when not existing.

    You are right, but that's not the point, I just picked it from a class method to a function vereyone could easily test. Fixed typo.

    I am on Linux and I'd like to hear some voice testing that on linux/*nix systems.

Similar Threads

  1. QDir::mkpath
    By drescherjm in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2009, 04:35
  2. Error spawning c1.exe?
    By vishal.chauhan in forum Installation and Deployment
    Replies: 5
    Last Post: 12th March 2008, 09:35
  3. QDir Subclassing
    By Oleg in forum Qt Programming
    Replies: 9
    Last Post: 31st October 2007, 12:03
  4. QDir and QFile
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 27th September 2007, 13:43
  5. Is it me or QDir?
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2007, 23:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.