How to check whether the tree view's item is expanded in delegate?



  • Hi,

    I'm developing a Qt application and I want to know whether the tree view's item is expanded in delegate function.

    Here is my tree view's delegate..

    @void roster_item_delegate::paint(QPainter painter,
    const QStyleOptionViewItem &option,
    const QModelIndex &index) const
    {
    /
    How can I know whether this item is expanded or not in here? */
    }@

    I think it's possible using the tree view's pointer and isExpanded() function, but I don't know how can I obtain the pointer in delegate function.

    Thank you.



  • Because it is your implementation of "roster_item_delegate" you can pass pointer to view through constructor or by some api like setView()/addView() with respect fact that one delegate can serve multiple views



  • A pointer to the view should be available in the option. qstyleoption_cast it to QStyleOptionViewItemV4 and check the widget member.



  • Thanks for your replies. I resolved my problem using the option's state.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.