[Qt-interest] help with getting all the files from a file

André Somers andre at familiesomers.nl
Sat Aug 29 14:56:05 CEST 2009


On Saturday 29 August 2009 12:40:07 pm Cimpean Andrei Sebastian wrote:
> Hello everybody. I was wondering if someone has any experience with
> QTableWidget and system folders and files and if maybe he could give me
> some advices. I have a QTableWidget that displays all files and folders.
> Each time I double click on a folder it automatically loads and displays
> the files and folders that have as parent the table item i double
> clicked. My problem is that i am also working with a database where i
> store strings that represent properties of a folder/file. The thing is
> that i do not want to save only a selected folder, i want to also save
> it's contents. So for this i pictured that i need to have a function
> that gets me the first level of children and the so on. Something like a
> graph. I wasn't very good at this things so I don't quite have an idea
> on how to do it. I am trying but can't find a solution to my problem so
> after 2-3 days i decided that maybe someone else can help me figure this
> thing out. Thank you very much in advance for all the help you can supply.
>
> Andrei
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

OK, first of all, this is not really Qt related. It is a general programming 
question. If I understand you correctly, you want to to build up a data 
structure representing a file system. The keyword here is recursion. You need 
to write a function that scans a directory, and for each directory it finds, 
call itself again. Note that there are limits to how deep you can do this, but 
for a file system you should be fine. 

Search for the term "recursive" in combination with programming concepts, and 
you should find some good pointers.

André




More information about the Qt-interest-old mailing list