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.

1

Sunday, June 13th 2010, 3:39pm

QTreeView include root in tree

A real QNewbie here ... this is my first foray into Qt programming.

I am trying to list a directory using QTreeView. The example at File browser tree works fine, but I would like to include the root dir in the tree (but no other files from the same level as root). In other words, assuming I am user hovercraft, what I get with the example is:

-bar
-baz
--naz
--naznaz
--naznaznaz
---todd-is-god
-boz
-foo


What I want is:

-hovercraft
--bar
--baz
---naz
---naznaz
---naznaznaz
----todd-is-god
--boz
--foo


Is there a nobrainer way to do this?

-M

ajg_itracs

Beginner

  • "ajg_itracs" is male

Posts: 20

Location: Scottsdale, AZ

Occupation: Software Engineer

  • Send private message

2

Monday, June 21st 2010, 6:24pm

Depending on what you need to accomplish this may be as simple as adding a root item yourself beforehand ... another option would be to load the tree from one level higher and reject the user folders and children you don't want but that is less efficient. This is not so much a QT question as a design choice. You could also do something along the lines of having a docking widget or group box around your tree view with the user folder name to identify the contents of the tree.
"Live as if you were to die tomorrow, learn as if you were to live forever" - Gandhi