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 Get The QTreeWidgetItem from QTreeWidget using a QWidget
Forum Updated to NodeBB v4.3 + New Features

How to Get The QTreeWidgetItem from QTreeWidget using a QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 244 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.
  • A Offline
    A Offline
    AbhiVarma
    wrote on last edited by
    #1

    Hi,

    I have a QTreeWidget object which has lots of QTreeWidgetItem's and some of these items have a QWidget. Now I have an QWidget object I want to get the corresponding QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?

    JonBJ 1 Reply Last reply
    0
    • A AbhiVarma

      Hi,

      I have a QTreeWidget object which has lots of QTreeWidgetItem's and some of these items have a QWidget. Now I have an QWidget object I want to get the corresponding QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @AbhiVarma said in How to Get The QTreeWidgetItem from QTreeWidget using a QWidget:

      and some of these items have a QWidget

      And how does that happen? Do you perchance use QTreeWidget::setItemWidget()?

      QTreeWidgetItem that has the same QWidget without iterating through all the items in QTreeWidget?

      You are basically out of luck. I would expect to have to iterate. setItemWidget() does not put anything into the widget so that its item/column can be retrieved. If it's really important to have fast lookup/back mapping, you might add this information to your widget(s) e.g. via QObject::setProperty(). I don't know how easy this might be to use if you adding/removing/moving your QTreeWidgetItems.

      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