Results 1 to 7 of 7

Thread: Qt4 QTreeView vs Qt3 QListView

  1. #1
    Join Date
    Jan 2006
    Posts
    31
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Qt4 QTreeView vs Qt3 QListView

    I have finally and successfully converted a 'difficult' Qt3 multi column list to a QT4 QTreeView.

    After:

    - Successfully converted all the functionality of a multi column list view, included a column containing a graph, and one with a custom pixmap added to remaining normal text and with background color content dependent.

    - Successfully obtained a very good loading speed, better then the super optimized and already fast Qt3 version.

    - Successfully used a custom model and a custom delegate to come up with the particular data to be displayed and the custom way to do it.


    I can finally say that the new QTreeView with his fellows QAbstractItemModel and QAbstractItemDelegate are... A PAIN IN THE ASS!

    My humble advice is 'do not use' unless you really need. You'll be asked to add tons of cruft to make the toy start working and, at the end, you'll get something that has the same functions of the old one but with three times the code.

    FWIK you get a real advantage ONLY if your application shows the same data in many different widget, and with different I mean different classes, not different objects.

    I really don't understand why Qt designers choose that over engineered, academic approach.

    Sorry for the rant, but I really like Qt and his API, this is the first time I hit the wall using it.

    Marco

  2. The following user says thank you to mcostalba for this useful post:

    gfunk (3rd January 2007)

  3. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 QTreeView vs Qt3 QListView

    There is another advantage - you can keep one data structure and then just add a model that exposes your application's internal data structures to the view of your choice.

  4. #3
    Join Date
    Jan 2006
    Posts
    31
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt4 QTreeView vs Qt3 QListView

    Why you should want this if you have only one kind of view?

    Your 'advantage' it's IMHO just another way (perhaps more specific) to say the same thing: if you have multple different views of the same data in your app then this new QxxxView stuff it's worth considering.

  5. #4
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Qt4 QTreeView vs Qt3 QListView

    Why not just use Qt4 QTreeWidget?
    Software Engineer



  6. #5
    Join Date
    Jan 2006
    Posts
    31
    Thanked 5 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Qt4 QTreeView vs Qt3 QListView

    I need to display custom graphs on a column and some other non standard stuff on another (pixmaps among text, background content dependent coloring, etc).

    And I need the list view to be very fast becuase the number of items could be high (more then 50000).


    Marco


    P.S: BTW did you know that on big lists QAbstractItemModel::index() is called by Qt much more then QAbstractItemModel::data(), also by a 100X factor?

    So if you have a row index (say the name of the resource you need) and a cooked index (say a pointer to the resource after a name lookup) you may want to return just the name in index() and perform the costly lookup only in data().

    QModelIndex MVCModel::index(int row, int column,
    const QModelIndex&) const {

    ......
    void* easyToGetPtr = getMyPointer(row, column);
    return createIndex(row, column, easyToGetPtr);
    }

    QVariant MVCModel::data(const QModelIndex& index, int role) const {

    ......

    QString* easyToGetPtr = static_cast<QString*>(index.internalPointer())

    MyData* ptr = lookup(easyToGetPtr)); // costly lookup

    .......
    }


    This trick can give a BIG boost to list view performance.

  7. #6
    Join Date
    Jan 2007
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 QTreeView vs Qt3 QListView

    I hate to revive this thread but it appears to me (from looking through the code) that QTreeWidget is perfectly fine if you don't need multiple columns, it's pretty much the same as making the "tutorial" model/view and you can't share the model.

    Anyone know any other reason it's a bad deal?

  8. #7
    Join Date
    Jan 2006
    Location
    Houston, TX
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 QTreeView vs Qt3 QListView

    From my perspective I think the problem for Qt people like me is that there was no compelling reason for Trolltech to "break" code like QListview. Qt4 QListView could have been made backward compatible with Qt3 QListView w/o disrupting the MVC approach used in the other classes.

    Instead Qt 4 QListView is now a single column list. I have approximately a hundred thousand lines of Qt 3 code that will take months to convert to Qt 4. I anticipate that the QListView issue will be a large component of that conversion.

    Also, I don't want to have to distribute the Qt3 support lib (2 meg) with all of my applications.

    I'm sure that Qt 4 is a much improved product, however, IMO, Trolltech could have done a better job in mitigating source code incompatabilties.

    Just my 2 cents.

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. Replies: 0
    Last Post: 10th November 2006, 13:46
  3. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24
  4. QSortFilterProxyModel & QTreeView
    By Bear in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:04
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 14:45

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.