Results 1 to 7 of 7

Thread: open a folder with Qt

  1. #1
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default open a folder with Qt

    Hi, sorry i searched this in net but i fund nothing! how can i open a folder in Qt?
    for example in this path:"c:\newfolder" I want to open "newfolder" folder by clicking a PushButton.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: open a folder with Qt

    Do you want to open the folder in the system's file manager? If so, QDesktopServices::openUrl() looks promising.

  3. The following user says thank you to yeye_olive for this useful post:

    Alex22 (8th January 2016)

  4. #3
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: open a folder with Qt

    this is exactly that i want. last question: i need also if "newfolder", in path "c:\newfolder", is not exist then first create "newfolder" and then open it and if it is exist, only open it.
    thanks for any help

  5. #4
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: open a folder with Qt

    Have a look at the QDir class. It has a method that creates a path.

  6. The following user says thank you to yeye_olive for this useful post:

    Alex22 (8th January 2016)

  7. #5
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: open a folder with Qt

    @yeye_olive, Thanks
    I fund this:

    Qt Code:
    1. QDir("newfolder").exists();
    2.  
    3. //To create "newfolder"
    4. QDir().mkdir("newfolder");
    To copy to clipboard, switch view to plain text mode 

  8. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,311
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: open a folder with Qt

    I hope you understand that your "solution" only works if you want to examine or create something in your current working directory. The QDir() constructor with no arguments returns a QDir instance pointing to the current working directory.

  9. The following user says thank you to d_stranz for this useful post:

    Alex22 (9th January 2016)

  10. #7
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: open a folder with Qt

    Quote Originally Posted by d_stranz View Post
    I hope you understand that your "solution" only works if you want to examine or create something in your current working directory. The QDir() constructor with no arguments returns a QDir instance pointing to the current working directory.
    Thanks a lot. I know d_stranz

Similar Threads

  1. Replies: 1
    Last Post: 21st August 2013, 23:23
  2. Intercept windows open folder
    By nasiroudin in forum Qt Programming
    Replies: 3
    Last Post: 12th February 2012, 19:49
  3. Files in the project folder won't open...
    By danoc93 in forum Newbie
    Replies: 2
    Last Post: 20th January 2012, 20:46
  4. Replies: 3
    Last Post: 26th September 2011, 14:14
  5. Multiplateform open folder in explorer
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2011, 08:27

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
  •  
Qt is a trademark of The Qt Company.