You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

klaus1111

Beginner

  • "klaus1111" started this thread

Posts: 7

Location: Germany-Stuttgart

  • Send private message

1

Tuesday, August 9th 2005, 12:17am

using entryInfoList with Qt4?

Hi, I try to travers a file structure. All examples I found are from Qt3. There it seems to works like this:

Source code

1
2
3
4
5
6
7
8
9
10
11
const QFileInfoList * files = thisDir.entryInfoList();
        if ( files ) {
            QFileInfoListIterator it( *files );
            QFileInfo * fi;
            while( (fi=it.current()) != 0 ) {
                   ++it;
                   if (fi->isdir()) {
                          // then do something
                   }
             }
         } 

Unfortunatly it seems to be different now. This is what I found on the trolltech page:

"fileInfoList(), entryInfoList(), and drives() now return a QList<QFileInfo> and not a QPtrList<QFileInfo> *. Code using these methods will not work with the Qt3Support library and will have to be adapted instead."

Interesting to know - but how? Can anybody send me a piece of Qt4 code, which loops the entrys of a directory?

P.S.: I know of the new QtreeView Class - but that is not what I'm searching for - I would like to traverse the tree by my own...

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

2

Tuesday, August 9th 2005, 9:51am

RE: using entryInfoList with Qt4?

I think you need to change the types used -- from pointers to objects.

Source code

1
2
3
4
5
6
7
QList<QFileInfo> &files = thisDir.entryInfoList();
if(files.empty()) break; // or something else
for(QList<QFileInfo>::iterator it = files.begin(); it!=files.end();++it){
  if((*it).isDir()){
    // then do something
  }
}


Something like that might work (not tested though).