Consult Great God , how can get to the content displayed ListWidget in which range in QListWidgetItems ;
example, now has 100 ListWidget Item, but now appears on the screen , only 10 , the other needs to show through the scrollbar .
How can we determine now displayed in the Item in QListWidgetItems which is located in the range ? such is 15-25 .
want to know how can determine this range ?
------ Solution ---------------------------------------- ----
reference to this function :
QModelIndex QAbstractItemView :: indexAt (const QPoint & point) const [pure virtual]
Returns the model index of the item at the viewport coordinates point.
viewport visible rect is able to achieve , and then calculate the uppermost and lowermost visible index is easy.
------ Solution ------------------------------------ --------
for larger models , I suggest you use QListView and QstandardModel the modelView model . Instead ListWidget this type.
In addition to the first floor of a method , you can try the following function .
QScrollBar ::
void setMaximum (int)
void setMinimum (int)
void setPageStep (int)
idea is that you have many pictures , you set the maximum value is the number, and then set the Step number of pictures per row . Then the current value from the scrollBar read in about which the picture is displayed . Functions like : int sliderPosition () const
------ eference ----------------------------- ----------
did not quite understand , to say in detail under it ?
------ eference --------------------------------------- < br> can you give points eXPRESS, study a little, or not understood. .
------ eference --------------------------------------- < br> how to get QModelIndex this corresponds QListWidgetItems after the index
------ eference ------------------------ ---------------
final solution is : m_listwidget-> indexAt (m_listwidget-> viewport () -> contentsRect (). center ()). row ( ) ;
Thank you very much 1st and 5th floor of help. Thanks to you to provide ideas . thank you!
没有评论:
发表评论