Results 1 to 8 of 8

Thread: Finding default delegate for QTreeView?

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

    Default Finding default delegate for QTreeView?

    tl;dr
    I am a PyQt user (Python binding of Qt), and am trying to figure out how Qt natively draws trees in QTreeView, as I am trying to recreate it using a custom delegate (QStyledItemDelegate applied to my view) just for instructive purposes. More specifically, I am viewing a QStandardItemModel using a QTreeView, and want to see the guts of the delegate that is used by default, but am having trouble finding the default 'paint' method. Is there a link to it?


    Details
    I am not very good at C++ (I'm a Python guy), and am having trouble figuring it out: I have been looking over the code at qtreeview.cpp but haven't actually found anything explicit where, for instance, the text is drawn corresponding to a particular item.

    Line 1389 has the `drawTree` method, which calls drawRow on line 1442:
    Qt Code:
    1. drawRow(painter, option, viewItems.at(i).index);
    To copy to clipboard, switch view to plain text mode 
    drawRow is defined starting on line 1473. Therein, I think we are reaching the guts, e.g., line 1679:
    Qt Code:
    1. d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex);
    To copy to clipboard, switch view to plain text mode 
    This suggests to me that that the delegate for the item associated with `modelIndex` is defined within `delegateForIndex`. But I have now hit the limits of my sleuthing, and am having trouble finding where this delegate, and its paint operation in particular, is defined.

    Any hints?

    ============
    Cross posted:
    http://stackoverflow.com/questions/3...treeview-in-qt
    Last edited by neuronet; 30th November 2015 at 01:01. Reason: linking to cross post at SO

Similar Threads

  1. Replies: 0
    Last Post: 23rd April 2015, 17:27
  2. QTreeView default drag action
    By onamatic in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2010, 07:37
  3. QTreeView Delegate
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2009, 09:10
  4. Default delegate displays empty QLineEdit?
    By andy.fillebrown in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2009, 13:13
  5. No delegate for 1 column in QTreeView
    By mace in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2007, 10:55

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
  •  
Qt is a trademark of The Qt Company.