Results 1 to 7 of 7

Thread: QTreeView details: what are viewItems?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2014
    Posts
    98
    Thanks
    43
    Thanked 4 Times in 4 Posts
    Platforms
    Windows

    Wink QTreeView details: what are viewItems?

    I am working on understanding trees, working through the simpletreemodel example that comes with Qt. I am working in PySide, not Qt, and while I don't know much c++ I often find it helpful to look at the Qt source code to help me understand what is happening.

    I understand indexes a bit (because of a thread here), and now am trying to understand QTreeView, in particular how it paints the initial tree, determines what to draw, when/where it calls model.rowCount() and other methods from my QAbstractItemModel subclass.

    I've been looking over qtreeview.cpp and am confused. My first confusion is about what the 'd' class is. I think it is an instance of QTreeView, because starting on line 196 we have:
    Qt Code:
    1. QTreeView::QTreeView(QTreeViewPrivate &dd, QWidget *parent)
    2. : QAbstractItemView(dd, parent)
    3. {
    4. Q_D(QTreeView);
    5. d->initialize();
    6. }
    To copy to clipboard, switch view to plain text mode 
    But there are lots of methods/attributes of d that I cannot find defined anywhere. For instance viewItems seems pretty key, and has many methods (e.g., resize(), clear()) that I'd like to study. Unfortunately I am not sure where viewItems is defined initially, what it means. I have never seen it documented, or used it explicitly in my custom views. In addition to qtreeview.cpp, I searched for it in qtreeview.h, qabstractitemview.cpp, and qabstractitemview.h.

    So I seem to be having a problem similar to when I was tracking down the definition of createIndex. Namely, figuring out where to find the relevant source code.

    More generally, anyone please let us know if you have seen a good nuts 'n' bolts explanation of how QTreeView works. I have found high-level descriptions of what is going on (e.g., the view uses indexes to determine what to paint to the screen), but I really want to know more under the hood. I have started putting print commands in the model for all the methods (e.g., rowCount), but this has made me even more confused: for instance, sometimes it is calling rowCount with input from a parent index from a row that is way below my selection.

    Thanks for reading.
    Last edited by neuronet; 1st January 2015 at 05:35.

Similar Threads

  1. QTreeView
    By marnando in forum Newbie
    Replies: 1
    Last Post: 13th March 2014, 08:06
  2. QTreeView and d&d
    By FuturePrimitive in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2011, 20:27
  3. Help ...QTreeView
    By Raymond in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2009, 09:18
  4. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  5. QTreeView
    By npc in forum Qt Programming
    Replies: 2
    Last Post: 24th January 2007, 07:53

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.