From kde-devel Tue Jul 27 14:12:32 1999 From: "Ming Poon" Date: Tue, 27 Jul 1999 14:12:32 +0000 To: kde-devel Subject: [Fwd: QListView column resizing wrong] X-MARC-Message: https://marc.info/?l=kde-devel&m=93308441826146 FYI ... -------- Original Message -------- Subject: QListView column resizing wrong Date: Tue, 20 Jul 1999 15:30:20 -0400 From: "Brian Rolfe" To: qt-bugs@troll.no CC: Ming Poon , Brian Jones In QListView (Qt 1.44), when using the automatic column resizing when entering data, the columns are resized wrong if you move the headers. Step one: Add some data to a multi column list Step two: Move the columns around with the mouse Step three: Add some more data that has smaller entries (text width) Result: The columns are resized improperly. What's happening is the code checks the width of the new data entered, and if larger, it resizes it to that size. But if the call to columnWidth() returns the width from the wrong column, say a small column, then the new data entered will seem larger so it will go on to resize it to that size. Problem being, it's now resized it to the new data which might be smaller than the data already in that column. Cause: QListView is calling methods to get/set the column sizes in QHeader. This is the code: int QHeader::cellSize( int i ) const { int s = pSize( i ); return s; } int QHeader::pSize( int i ) const { return data->sizes[mapToLogical(i)]; } void QHeader::setCellSize( int i, int s ) { data->sizes[i] = s; } As you can see, the "cellSize()", which calls "pSize()" calls "mapToLogical()" while the "setCellSize()" does not. This is the root of the problem.....but it can be fixed in QListView QListView code: int QListView::columnWidth( int c ) const { return d->h->cellSize(c); } void QListView::setColumnWidth( int column, int w ) { ASSERT( column < d->h->count() ); if ( d->h->cellSize( column ) != w ) { d->h->setCellSize( column, w ); d->h->update(); // ##### paul, QHeader::setCellSize should do this. } } To fix, the columnWidth() method call mapToActual() to reverse the mapToLogical() call in QHeader. Then make setColumnWidth() call columnWidth() to get the width. P.S.: I briefly looked at Qt 2.0 and it's looks pretty much the same there. --Brian R