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. Accessing an item in QTreeWidget
Qt 6.11 is out! See what's new in the release blog

Accessing an item in QTreeWidget

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 4.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.
  • T Offline
    T Offline
    TheDestroyer
    wrote on last edited by
    #1

    Hello guys,

    I have a QTreeWidget, in which I inserted 3 parent items, and each parent item has a few child items, all with a single column. I succeeded in putting them in the positions I wanted them to be and they show the text they're supposed to show.

    For some reason, I'm unable to access the second and third parent items. The code looks as follows:

    @
    filterOptions = new QTreeWidget(this);
    //(add items code)
    filterOptions->itemAt(0,i)->child(k)->checkState(0); // i is supposed to be the parent item number, and k the child number. But whatever i is, it returns the first parent item!!!
    @

    Could you guys please explain how I can access some parent widget with a mere row/index number? the item from index function is protected and doesn't help.

    Thank you for any efforts :-)

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

      itemAt returns items at a screen position (using QPoint or x/y coordinates).

      You want to use "QTreeWidget::topLevelItem() ":/doc/qt-4.8/qtreewidget.html#topLevelItem.

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

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheDestroyer
        wrote on last edited by
        #3

        Thanks a lot :)

        I wanted to post this since yesterday, but this stupid forum is so stubborn to accept some replies!!! I wish they could fix this problem because it's making me hate the forum.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          What kind of error do you get?
          Note that yesterday, the forum was moved to a new domain, and was thus in read-only mode for a couple of hours.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vinothrajendran4
            wrote on last edited by
            #5

            thanks.........

            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