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. [SOLVED]QTreeWidget position of columns
Qt 6.11 is out! See what's new in the release blog

[SOLVED]QTreeWidget position of columns

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.2k Views 2 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.
  • BlackMambaB Offline
    BlackMambaB Offline
    BlackMamba
    wrote on last edited by
    #1

    Hello,
    I have a QTreeWidget with some items in 4 columns, from index 0 to 3.
    I want to have the position of where the last column starts (x position).

    I tried

    @treeWidget->topLevelItem(0)->child(3) but this has no pos() method available.@

    How could I acheieve that?

    Cheers,

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you mean by x ? the pixel coordinate ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • BlackMambaB Offline
        BlackMambaB Offline
        BlackMamba
        wrote on last edited by
        #3

        Hello SGaist,
        Yes the pixel coordinate. The same as pos().x() on, a widget ;)
        Cheers

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you can try visualRect(const QModelIndex &)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Aleksey_KA 1 Reply Last reply
          0
          • BlackMambaB Offline
            BlackMambaB Offline
            BlackMamba
            wrote on last edited by
            #5

            Yes :)
            I also found :

            @treeWidget->header()->sectionPosition(3);@

            which might be the easiest way to go ;)

            Thanks SGaist

            1 Reply Last reply
            0
            • SGaistS SGaist

              Then you can try visualRect(const QModelIndex &)

              Aleksey_KA Offline
              Aleksey_KA Offline
              Aleksey_K
              wrote on last edited by
              #6
              This post is deleted!
              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