Results 1 to 3 of 3

Thread: QAbstractItemModel subclass for a treeview

  1. #1
    Join Date
    Jun 2008
    Location
    The Netherlands
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QAbstractItemModel subclass for a treeview

    Hello,

    I am currently working on a frontend for the "ls" command. I supply the -R command-line argument so it's QProcess output is recursive: that means it's output looks like this:

    .:
    lol.bat
    file1.txt
    file2.txt
    file3.txt
    ./usr/

    ./usr:
    textfile.txt
    otherfolder/

    ./usr/otherfolder:
    textfile2.txt

    I want this output to be viewed in a QDirView-like way, in a treeview. A QAbstractItemModel subclass seemed to be the best solution. On the Trolltechs website I found example code: Simple Tree Model. This code is implemented in my project but now I'm wondering how to properly modify this code to suit my needs.

    Currently every time my QProcess emits the readyReadStandardOutput signal a new TreeModel gets constructed with the output of from the QProcess. I strongly feel this is not the best solution. Here's a snippet from my code:
    Qt Code:
    1. void MainWindow::ViewDirReadStandardOutput()
    2. {
    3. TreeModel *model = new TreeModel(ls->readAll());
    4. treeServer->setModel(model);
    5. }
    To copy to clipboard, switch view to plain text mode 

    The Simple Tree Model example can be found here: http://doc.trolltech.com/4.4/itemvie...treemodel.html

    I'm quite new to Qt, this is my first application and I really hope someone can help me out with this.

    Best regards,
    pvdk.
    Last edited by pvdk; 24th June 2008 at 15:35.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QAbstractItemModel subclass for a treeview

    Isn't QFileSystemModel suitable for you?
    J-P Nurmi

  3. #3
    Join Date
    Jun 2008
    Location
    The Netherlands
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QAbstractItemModel subclass for a treeview

    Quote Originally Posted by jpn View Post
    Isn't QFileSystemModel suitable for you?
    I whish it was but the output from ls is actually from a remote machine, trough SSH. Thanks anyway

Similar Threads

  1. Replies: 1
    Last Post: 2nd February 2007, 08:42

Tags for this Thread

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.