Results 1 to 3 of 3

Thread: QDirModel displaying Desktop and Documents

  1. #1
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QDirModel displaying Desktop and Documents

    Hi, I'm using a QDirModel with a treeview to implement a windows explorer-like interface. I'd like to be able to also add directories for Desktop and MyDocuments (or equivalent) in the parent directory, where it shows the hard drives.

    I'm totally new to using a model/view type interface. Can someone point me in the right direction to be able to do this?

    Just to test, I hard coded myDirModel->index("desktopfilepath") and then use the returned QModelIndex to create a new directory by calling myDirModel->mkdir(returnedIndex, "name"); This did not work, however. What am I doing wrong?

    Thanks, Daniel

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDirModel displaying Desktop and Documents

    You can't just add new entries to the directory tree on the root level. Unfortunately QDirModel doesn't show Desktop and My Documents entry and there is no easy way to make it work. You have to subclass the model and handle those entries in the subclass or implement a proxy model that would map proper indexes. It's not a 10 minute task, though. If you decide to do it, I'd go for the proxy approach. Also search the forum, there was a thread describing a similar problem about 2 months ago.

  3. #3
    Join Date
    Sep 2007
    Location
    Rome, GA
    Posts
    199
    Thanks
    14
    Thanked 41 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDirModel displaying Desktop and Documents

    Thanks for the advice, it was time-sensitive so I ended up just emulating the filesystem with a QTreeWidget. Wasn't as much trouble as I thought it'd be.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.