Results 1 to 2 of 2

Thread: Problem with QDir::cdUp()

  1. #1
    Join Date
    Mar 2010
    Location
    Bangkok, THAILAND
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question Problem with QDir::cdUp()

    Hello everyone. Now I want to access the parent directory by using cdUp(). For example, when the current directory is C:\SampleRoot\SampleFolder and I'd like to access C:\SampleRoot:

    Qt Code:
    1. QDir tmpCurrDir = QDir::current();
    2. tmpCurrDir.cdUp();
    3. QString rootDir = tmpCurrDir.currentPath();
    To copy to clipboard, switch view to plain text mode 

    Even if there is a existed directory and cdUp() always return true, but when calling the currentPath() it will give C:\SampleRoot\SampleFolder not C:\SampleRoot. So what should I do?

    Thanks a lot for everyone!

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Problem with QDir::cdUp()

    From the docs:
    QString QDir::currentPath () [static]
    Returns the absolute path of the application's current directory.
    Use QDir:: path() instead
    Qt Code:
    1. QString rootDir = tmpCurrDir.path();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDir::mkpath
    By drescherjm in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2009, 04:35
  2. QDir Path problem
    By ToddAtWSU in forum Qt Programming
    Replies: 3
    Last Post: 21st August 2008, 12:15
  3. Help with QDir model
    By allstar in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2007, 15:31
  4. qdir and entrylist
    By mattia in forum Newbie
    Replies: 1
    Last Post: 28th November 2007, 10:13
  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.