Results 1 to 3 of 3

Thread: QDir::setCurrent

  1. #1
    Join Date
    Dec 2015
    Posts
    35
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QDir::setCurrent

    Hi,

    I can't change the working directory using Qdir::setCurrent, it returns false
    I used it with QProcess
    Qt Code:
    1. QProcess process;
    2. QString cloneProject;
    3. bool cloneOk = false;
    4. QString dir = path;
    5.  
    6. qDebug() << QDir::current();
    7.  
    8. QDir::setCurrent(dir);
    9. QDir directory(dir);
    10. qDebug() << QDir::current();
    11.  
    12. cloneProject = "git clone ssh://user@host:port/"+project+".git";
    13. process.start(cloneProject);
    To copy to clipboard, switch view to plain text mode 
    Last edited by RegMe; 3rd June 2016 at 10:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDir::setCurrent

    Is "path" a valid directory?

    Also, why change your program's current working directory if you want to change the one of the QProcess?

    Cheers,
    _

  3. #3
    Join Date
    Dec 2015
    Posts
    35
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QDir::setCurrent

    Qt Code:
    1. qDebug() << QDir::current();
    2.  
    3. QDir::setCurrent(dir);
    4. QDir directory(dir);
    5.  
    6. qDebug() << directory;
    7.  
    8. qDebug() << QDir::current();
    9.  
    10. cloneProject = "git clone ssh://user@host:port/"+project+".git";
    11. process.start(cloneProject);
    To copy to clipboard, switch view to plain text mode 

    Console out :
    QDir( "/home/.../key/bin" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
    QDir( "/home/.../Plg_mgm" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )
    QDir( "/home/.../key/bin" , nameFilters = { "*" }, QDir::SortFlags( Name | IgnoreCase ) , QDir::Filters( Dirs|Files|Drives|AllEntries ) )


    Added after 7 minutes:


    Thanks, the problem is solved

    Problem was in the path creation
    Last edited by RegMe; 3rd June 2016 at 11:01.

Similar Threads

  1. QDir sort by QDir::Type problem
    By tsuibin in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2016, 08:36
  2. How to use? And where to put QDir?
    By JaySDC in forum Qt Quick
    Replies: 12
    Last Post: 21st September 2015, 08:42
  3. QDir
    By smemamian in forum Newbie
    Replies: 3
    Last Post: 2nd April 2013, 07:55
  4. QDir::setCurrent with resource files
    By LarryERamey in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2011, 02:21
  5. Is it me or QDir?
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2007, 23:06

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.