[Issue N7298] [PATCH] QListBox ensureCurrentVisible() brokenness...
qt-bugs at trolltech.com
qt-bugs at trolltech.com
Mon Sep 30 14:31:54 BST 2002
On Monday, 23 Sep 2002 20:05 Scott Wheeler wrote:
> Currently with QListBox, there are calls to ensureCurrentVisible() in
> a few
> problematic places. Specifically it is called in resizeEvent() and
> refreshSlot() (which is called by triggerUpdate(true)).
>
> There are a few basic problems that this causes when you are using a
> QListBox
> that is larger than the view frame. First, all calls to
> triggerUpdate() will
> artificially force the QListBox to scroll back to the selected item.
> This is
> where I initially noticed the bug, but when looking through the
> source, I
> noticed the same things happens with resizeEvent() and
> triggerUpdate(true) is
> also called by removeItem(). This affects Qt 3.0.6 and 3.1 Beta.
>
> Cheers,
>
> -Scott
Hi Scott
The following has been applied to Qt. Thanks for reporting this one.
==== //depot/qt/3.0/src/widgets/qlistbox.cpp#48 (text) ====
@@ -1590,8 +1590,11 @@
void QListBox::removeItem( int index )
{
+ bool wasVisible = itemVisible( currentItem() );
delete item( index );
triggerUpdate( TRUE );
+ if ( wasVisible )
+ ensureCurrentVisible();
}
@@ -3646,8 +3649,10 @@
if ( d->mustPaintAll ||
d->layoutDirty ) {
d->mustPaintAll = FALSE;
+ bool currentItemVisible = itemVisible( currentItem() );
doLayout();
if ( hasFocus() &&
+ currentItemVisible &&
d->currentColumn >= 0 &&
d->currentRow >= 0 &&
( d->columnPos[d->currentColumn] < contentsX() ||
best regards
Anders Bakken - Trolltech AS, W. Thranes gt. 98, N-0175 Oslo, Norway
More information about the kde-core-devel
mailing list