Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Meet problem when use "QTreeWidgetItem::DontShowIndicator"

Meet problem when use "QTreeWidgetItem::DontShowIndicator"

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 2.2k Views
  • 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.
  • N Offline
    N Offline
    nan3113
    wrote on last edited by
    #1

    when I use setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator) with a node, then the node's children can't be shown, collapse/expand can't be used, but I just want minus/plus sign dont show.
    @
    TreeWidgetItem *root=tree->invisibleRootItem();
    myDeviceItem = new QTreeWidgetItem(root);
    myDeviceItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
    myDeviceItem->setText(0,"My Devices");
    myDeviceItem->setIcon(0,QIcon(":/icons/house.ico"));

    publishItem = new QTreeWidgetItem(myDeviceItem);
    publishItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
    publishItem->setText(0,"Publish");
    publishItem->setIcon(0,QIcon(":/icons/right.ico"));
    
    subscribeItem = new QTreeWidgetItem(myDeviceItem);
    subscribeItem->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
    subscribeItem->setText(0,"Subscribe");
    subscribeItem->setIcon(0,QIcon(":/icons/left.ico"));
    

    @

    Edit: Please wrap your code in @ tags; mlong

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      Instead of using setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator), you can try modifying the drawing of the branches to not draw the minus/plus sign in the style by reimplementing "drawPrimitive()":http://doc.qt.nokia.com/4.7/qstyle.html#drawPrimitive and modifying the "QStyle::PE_IndicatorBranch":http://doc.qt.nokia.com/4.7/qstyle.html#PrimitiveElement-enum element. Does doing so help?

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nan3113
        wrote on last edited by
        #3

        Thanks,sigrid, I define a class inheriting QWindowsStyle,and then reimplement its drawPrimitive() as below:
        @

        void IndicatorNoneStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter p, const QWidget w) const
        {
        QStyleOption
        op = const_cast<QStyleOption
        >(opt);
        op->state &= ~ QStyle::State_Children;
        QWindowsStyle::drawPrimitive(pe, op, p, w);
        }

        @

        that works correctly. cool you are

        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