Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to check whether the tree view's item is expanded in delegate?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    superkkt
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yshurik
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

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

        Software Engineer
        KDAB (UK) Ltd., a KDAB Group company

        1 Reply Last reply
        0
        • S Offline
          S Offline
          superkkt
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved