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. Setting a QTreeWidget's current item to the last item does not set the scrollbar to its max value

Setting a QTreeWidget's current item to the last item does not set the scrollbar to its max value

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

    Mac OS X 10.13.6
    Qt 5.11.2

    If you set a QTreeWidget's current item to the last item, the scrollbar's value is set to maximum-1 rather than maximum.

    Does anyone know why this is, or if there's any way to make it actually go to the max?

    tree->setCurrentItem(tree->topLevelItem(tree->topLevelItemCount()-1));

    The above will always set the scrollbar's value to maximum-1.

    qDebug() << tree->verticalScrollBar()->value() << tree->verticalScrollBar()->maximum()

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

      Hi,

      What if you use QTreeWidget::scrollToItem ?

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

      btseB 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What if you use QTreeWidget::scrollToItem ?

        btseB Offline
        btseB Offline
        btse
        wrote on last edited by btse
        #3

        @SGaist Produces the same result, maximum - 1.

        This got changed at some point in Qt5. In Qt4.8, it worked as you would expect.

        I tested the different ScrollHints:

        • Default EnsureVisible is max-1
        • PositionAtTop correctly is set to max
        • PositionAtBottom max-1
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you check with the latest 5.12 to see if you have the same behaviour ?

          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
          0

          • Login

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