View Full Version : open a folder with Qt
Alex22
7th January 2016, 21:05
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.
yeye_olive
7th January 2016, 23:32
Do you want to open the folder in the system's file manager? If so, QDesktopServices::openUrl() looks promising.
Alex22
8th January 2016, 05:51
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
yeye_olive
8th January 2016, 09:14
Have a look at the QDir class. It has a method that creates a path.
Alex22
8th January 2016, 09:23
@yeye_olive, Thanks
I fund this:
QDir("newfolder").exists();
//To create "newfolder"
QDir().mkdir("newfolder");
d_stranz
9th January 2016, 15:25
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.
Alex22
9th January 2016, 15:29
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.