PDA

View Full Version : The correct widget for a file/directory listing?



invictus
4th November 2007, 09:52
Hi

I am looking into the examples provided by QT and see that they use a QTreeView and QDirModel to show a list of files. I also noticed that I could use QDirModel and QListView to get a list without details.

My question is; If I only want the list of files (with details) but not a tree, what widget is the most correct one to use? I know I can use setRootIsDecorated and setItemsExpandable to achieve the desired result with QTreeView, but I just want to know if this is OK or if there is a better widget for this purpose?

Also; When I use the QTreeView with the mentioned options I get no way of traversing the filetree (since the tree is gone). How can I make directories "clickable" so the QDirModel changes to the supplied directory?

Trying to learn the basics :)

jpn
4th November 2007, 10:18
Yes, QTreeView is the best choice for a "detailed view", a multi-column list. See this thread: http://www.qtcentre.org/forum/f-qt-programming-2/t-suggestionsideas-about-a-file-browser-1625.html.

invictus
4th November 2007, 10:55
It is just a bit weird to use a Tree when I am not interested in a tree at all...

jpn
4th November 2007, 11:11
That's just the way it is in Qt 4. QListView is a "flow" of items from top to bottom or from left to right. There is no such concept as "column" when it comes to QListView in Qt 4.

invictus
4th November 2007, 11:23
How about QTable?

jpn
4th November 2007, 11:35
Well, you could use QTableView too, but it's not so umm.. sophisticated? ;) Take a look at the widget gallery and you'll see the difference: http://doc.trolltech.com/4.3/gallery-plastique.html