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

QListVIew page turning error

    XMLWordPrintable

Details

    • Linux/X11
    • c77840d734883c91079c942e052cbdc0994c2f01 (qt/qtbase/dev) bd73184395aa25b5736449b8e99c8111661bef24 (qt/qtbase/6.1)

    Description

      Description: When the size of a certain itme is different from others, Click key PageDown,The cursor position is displayed abnormally.Like the attached video.

      Steps:  Run the program and press Page Down on the keyboard. Observe the currently selected item

       

      Reason: In the moveCursor function of QListview,

      rect.moveTop(rect.top() + d->viewport->height()-2 * rect.height()); 

      When the first item is relatively large, subtract 2* rect.height() Make the cursor position calculation abnormal.

       

      Hope: Regardless of the size of the item, turning the page can jump to a page normally.

       

       

      #include <QApplication>
      #include <QHBoxLayout>
      #include <QListView>
      #include <QStandardItem>
      #include <QDebug>
      #include <QItemSelectionModel>
      #include <QPushButton>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          a.setStyle("fusion");
      
          QWidget w;
          QListView *listView = new QListView(&w);
      
          QHBoxLayout *layout = new QHBoxLayout(&w);
          layout->addWidget(listView);
      
          QPushButton* button = new QPushButton;
          layout->addWidget(button);
      
          QObject::connect(button ,&QPushButton::clicked,[=](){
              qWarning() << "asdasd";
          listView->selectAll();
          });
          //listView->setWordWrap(true);
      
      
          QStandardItem *it1 = new QStandardItem("abcdefghiqweyufasdfashdfashdf");
          QStandardItem *it2 = new QStandardItem("bcdefghiqweyufasdfashdfashdfl");
          QStandardItem *it3 = new QStandardItem("132465468798794");
          QStandardItem *it4 = new QStandardItem("q111");
          QStandardItem *it5 = new QStandardItem("q222");
          QStandardItem *it6 = new QStandardItem("q333");
          QStandardItem *it7 = new QStandardItem("q444");
          QStandardItem *it8 = new QStandardItem("q555");
          QStandardItem *it9 = new QStandardItem("q666");
          QStandardItem *it10 = new QStandardItem("q777");
          QStandardItem *it11 = new QStandardItem("q888");
          QStandardItem *it12 = new QStandardItem("q999");
          QStandardItem *it13 = new QStandardItem("q000");
      
          QStandardItem *it14 = new QStandardItem("w111");
          QStandardItem *it15 = new QStandardItem("w222");
          QStandardItem *it16 = new QStandardItem("w333");
          QStandardItem *it17 = new QStandardItem("w444");
          QStandardItem *it18 = new QStandardItem("w555");
          QStandardItem *it19 = new QStandardItem("w666");
          QStandardItem *it20 = new QStandardItem("w777");
          QStandardItem *it21 = new QStandardItem("w888");
          QStandardItem *it22 = new QStandardItem("w999");
          QStandardItem *it23 = new QStandardItem("w000");
      
          QStandardItemModel *model = new QStandardItemModel;
          listView->setModel(model);
      
         QFont font = it1->font();
         font.setPixelSize(50);
         font.setBold(true);
         it1->setFont(font);
      
          model->appendRow(it1);
          model->appendRow(it2);
          model->appendRow(it3);
          model->appendRow(it4);
          model->appendRow(it5);
          model->appendRow(it6);
          model->appendRow(it7);
          model->appendRow(it8);
          model->appendRow(it9);
          model->appendRow(it10);
          model->appendRow(it11);
          model->appendRow(it12);
          model->appendRow(it13);
          model->appendRow(it14);
          model->appendRow(it15);
          model->appendRow(it16);
          model->appendRow(it17);
          model->appendRow(it18);
          model->appendRow(it19);
          model->appendRow(it20);
          model->appendRow(it21);
          model->appendRow(it22);
          model->appendRow(it23);
      
      
      
      
          w.show();
      
      
      
          return a.exec();
      }
      
      

      Attachments

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tanghaixiang haixiang tang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: