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 QTreeWidgetItem position?
Qt 6.11 is out! See what's new in the release blog

How to get QTreeWidgetItem position?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.6k 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.
  • F Offline
    F Offline
    flammmable
    wrote on last edited by
    #1

    How shall I get a QTreeWidgetItem LeftTop position (in pixel) after I get this item with the itemAt?

    F 1 Reply Last reply
    0
    • F flammmable

      How shall I get a QTreeWidgetItem LeftTop position (in pixel) after I get this item with the itemAt?

      F Offline
      F Offline
      flammmable
      wrote on last edited by
      #5

      @flammmable

      treeWidget()->itemWidget(poTreeItem,0)->rect().topLeft();
      

      https://stackoverflow.com/q/55352805/10069064

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #2

        The item has no visual representation it's just pure data. It's the view/delegate that takes care of representing visually the item.

        Why do you need that position?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        F 1 Reply Last reply
        0
        • VRoninV VRonin

          The item has no visual representation it's just pure data. It's the view/delegate that takes care of representing visually the item.

          Why do you need that position?

          F Offline
          F Offline
          flammmable
          wrote on last edited by flammmable
          #3

          @VRonin I need the position to define border coordinates of item. And then I will make a height resize of the item (when a mouse cursor drag a border).

          It is strange. I can set height of an item with

          QSize height; 
          height.setHeight(123); 
          item->setSizeHint(0, height);
          

          But I can not get coordinates of an item.

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #4

            All you are trying to do should be done by subclassing QStyledItemDelegate

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2
            • F flammmable

              How shall I get a QTreeWidgetItem LeftTop position (in pixel) after I get this item with the itemAt?

              F Offline
              F Offline
              flammmable
              wrote on last edited by
              #5

              @flammmable

              treeWidget()->itemWidget(poTreeItem,0)->rect().topLeft();
              

              https://stackoverflow.com/q/55352805/10069064

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #6

                itemWidget is not the way to go. the delegate is the scalable solution

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                1 Reply Last reply
                1

                • Login

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