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. How to get rid of expande/collapse +/- QTreeWidgetItem indicator?
Forum Updated to NodeBB v4.3 + New Features

How to get rid of expande/collapse +/- QTreeWidgetItem indicator?

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 4 Posters 15.2k 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.
  • M Offline
    M Offline
    mmesarina
    wrote on last edited by
    #1

    Hi,

    I read in the documentation that I can get rid of the +/- indicator with the setChildIndicatorPolicy method of hte QTreeWidgetItem class. And I did it with the following code. But i can still see the indicator when I run the code.
    Does anyone know what could possibly be wrong? Am I using the right method?
    Thank you.

    @
    QTreeWidgetItem *item2 = new QTreeWidgetItem();
    item2->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);

    @

    -Malena

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Just tested locally, this works:

      @
      TreeViewTestForm::TreeViewTestForm(QWidget *parent) :
      QWidget(parent),
      ui(new Ui::TreeViewTestForm)
      {
      ui->setupUi(this);

      QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
      item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
      item->setText(0, "abc");
      
      QTreeWidgetItem *item2 = new QTreeWidgetItem(item);
      //item2->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicator);
      item2->setText(0, "xxxx");
      

      }
      @

      I see no significant difference to your code (despite the missing parents to the item constructors).

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • H Offline
        H Offline
        helios66
        wrote on last edited by
        #3

        same view.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mmesarina
          wrote on last edited by
          #4

          Thank you Volker. I will copy your code to a new project and test it on my end. See if that may help me debug the problem.

          -Malena

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mmesarina
            wrote on last edited by
            #5

            Volker, your code still shows root decorations on my end. I figured a method that worked for me. The following line got rid of the expansion indicators and root decoration:

            treeWidget->setRootIsDecorated(false);

            -Malena

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              Hi mmesarina,

              there is a difference in showing a root item and showing the expand / collapse items.
              Removing the rpoot is possible by setRootIsDecorated(false);, the other one by the solution given by Volker. But rootDecoration != expand/collaps indicator

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mmesarina
                wrote on last edited by
                #7

                Hi Gerolf,

                yeah, I know the difference after reading about the root decorator and the expandable symbols (+/-) . As I mentioned in my first post I had already tried using the setChildIndicatorPolicy() method of the QTreeWidgetItem, as Volker also did.
                I tried Volker code and his code works in the sense that it does not show the expandable icons. (at first I thought the root decorator his code showed was part of the expandable icons, but i realized that it was a root decorator later).
                In any case, setChildeIndicatorPolicy() works in his example but when I applied it in my code it doesn't.
                So I read more and the documentation and found that the QTreeWidget->setRootIsDecorated() is another way to control the appearance of the expandable icons.
                Below is the definition straight from the Qt 4.7 documentation, and it works in my code. But I am still not satisfied that the setChildIndicatorPolicy() of the QTreeWidgetItem class is not working.

                From Documentation:
                http://doc.qt.nokia.com/4.7-snapshot/qtreeview.html#rootIsDecorated-prop

                rootIsDecorated : boolThis property holds whether to show controls for expanding and collapsing top-level items.

                Items with children are typically shown with controls to expand and collapse them, allowing their children to be shown or hidden. If this property is false, these controls are not shown for top-level items. This can be used to make a single level tree structure appear like a simple list of items.

                By default, this property is true.

                Access functions:

                bool rootIsDecorated () const
                void setRootIsDecorated ( bool show )

                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