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. Relative positions of widgets

Relative positions of widgets

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

    Hello,

    I encounter the following problem:
    I have a QTreeWidget which inherits QAbstractScrollArea. When the tree is long enough, the vertical scroll bars appears.

    I wouls like to know the position od the tree window ( in pixel or whatever ) inside that QAbstractScrollArea.
    For example, when the tree is small enough for the scroll to be dissabled, this position is 0;
    And when for example there ten items above the first item visible, I'd like the length of all those items which corresponds to the distance from the begining of the tree.

    Is there a way to do it?

    Thanks

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

      The tree view is not inside the QAbstractScrollArea, it is an QAbstractScrollArea.

      QAbstractItemView provides a method visualRect() to retreive the rect of an item, and you can map positions to using the viewPorts()'s mapTo... methods.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        evergreen
        wrote on last edited by
        #3

        Thanks for the answer.
        Okay, but I don't see how that could help me. I want to know the position of the tree compared to the area. If we can only the the second half o the tree for example, how could i know?

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

          The information above really gives you all the tools you need.

          I am wondering: what do you need this information for?

          1 Reply Last reply
          0
          • E Offline
            E Offline
            evergreen
            wrote on last edited by
            #5

            When a browse all items of my tree and apply a treatement on them, the scrolling goes down automaticaly. I would like to know the position of the tree before the treatement to set it back after the treatement. I managed to do it by getting the value of the scrollbar and set it after the treatement, it works but too slowly. I figured if I could directly get the position of the tree inside the area it could be more perfomrmant.

            It might not be clear. Sorry for that.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              evergreen
              wrote on last edited by
              #6

              After some more works, the problem could be change.

              In fact, during the treatement I apply on each items, I use the method :
              @void QTreeWidget::setCurrentItem ( QTreeWidgetItem * item, int column, QItemSelectionModel::SelectionFlags command ) @

              to change their selection.

              It turns out that the fact of using such a method on items that are too deep into the tree for being directly visible automaticaly makes the view of the tree change in order to make them visible.
              Of course I don't want the view of the tree to change when those action are performed.

              Anyone has a idea to forbid that update of the display of the tree?

              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