Thanks aamer4u! Your suggestion helped me.
But I still have a problem. I'm sorry I was not very clear about my statement,
. I would like to draw the first and last visible items with smaller dimension particularly the height
What I exactly mean is that I need tor draw the "first visible" and "last visible" items in the list with smaller dimensions. I already have a function to determine the first visible and last visible items (thanks to wysota), using the QListWidget function "indexAt". But when I tried calling these functions inside my custom QAbstractItemDelegate::sizeHint it always throws me a segmentation fault. Let me illustrate below,
The ff. is how I get the first visible item (similar with the last visible item), these code are in my custom QAbstractItemDelegate::sizeHint function.
QListWidget * parent
= dynamic_cast<QListWidget
*>
(this
->parent
());
if(parent)
{
QModelIndex firstIndex
= QCustomUtils
::getInstance()->firstVisibleItem
(parent
);
--->
this caused a segmentation fault some
time, sometimes its ok
if(index.row() == firstIndex.row())
{
reduce size of first visible item
}
// do similar with last visible item
// return custom size hint
QListWidget * parent = dynamic_cast<QListWidget*>(this->parent());
if(parent)
{
QModelIndex firstIndex = QCustomUtils::getInstance()->firstVisibleItem(parent); ---> this caused a segmentation fault some time, sometimes its ok
if(index.row() == firstIndex.row())
{
reduce size of first visible item
}
// do similar with last visible item
// return custom size hint
To copy to clipboard, switch view to plain text mode
What could be the reason for the segmentation fault? The "first visible" and "last visible" items in the list are dynamic, they can be any of the rows. So checking just the row would not be sufficient. Do you have any other ideas about this, or how should I do this?
Bookmarks