Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77300

QAbstractItemView does not calculate item size correctly resulting in empty space

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.2, 5.13.0
    • Widgets: Itemviews
    • None
    • Windows

    Description

      Let's say we have an item view as in QComboBox and we insert a few normal strings. If we insert spacer which is not visible on the first page (limited by MaxVisibleItems) the list leaves an empty space at end when we scroll to bottom. Empty space's height is exactly (NormalItemHeight) - (SpacerHeight). But if we also insert a spacer so it is visible on the first page (indexNumber falls under MaxVisibleItems) then there will be no empty space.

      As far as I know something doesnt work out between View and ScrollBars. Scroll bar jumps between Items (QAbstractItemView::ScrollPerItem") but it doesnt adjust step correctly based on item height. 

      Code that displays EMPTY SPACE (image 'empty_space.png'):

      // code placeholder
      QComboBox *combo_box = new QComboBox();
      combo_box->setMaxVisibleItems(4);
      
      combo_box->addItem("dude1");
      combo_box->addItem("dude2");
      combo_box->addItem("dude3");
      combo_box->addItem("dude4");
      combo_box->addItem("dude5");
      combo_box->addItem("dude6");
      combo_box->insertSeparator(combo_box->count());
      combo_box->addItem("dude7");
      

       

      Code that displays correctly (image 'no_empty_space.png'):

      // code placeholder
      QComboBox *combo_box = new QComboBox();
      combo_box->setMaxVisibleItems(4);
          
      combo_box->insertSeparator(combo_box->count());
      combo_box->addItem("dude1");
      combo_box->addItem("dude2");
      combo_box->addItem("dude3");
      combo_box->addItem("dude4");
      combo_box->addItem("dude5");
      combo_box->addItem("dude6");
      combo_box->insertSeparator(combo_box->count());
      combo_box->addItem("dude7");
      

       

      Attachments

        1. empty_space.png
          empty_space.png
          14 kB
        2. no_empty_space.png
          no_empty_space.png
          15 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            matijalazic Matija Lazić
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes