TreeView item width set to -1 and do not show
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
Fixes for Mantis' 27043, 27696, and 26770 set the sizeHint for QTreeWidgetItems. The height is always set but the width is only being set if ImageIndex = -1. If ImageIndex > -1 then width is left at default -1.
Steps to reproduce:
Use attached example project.
Additional information:
Qt code assumes that if one sizeHint value (QSize.cy or QSize.cx) is set then both are valid and it will use those values and not do any calculations for height or width. This means that if one value is calculated and set then both need to be calculated and set. This problem first arose with the fix to 27043 that first changed sizeHint. Without that change then 27696, 26770, and this problem do not arise.
So I am suggesting that all the changes starting with 27043 be pulled out and a different approach put in (see attach diff files).
The change is to not set sizeHint but do the same thing through the ItemDelegateSizeHint. This allows the height to be modified to match imagelist.height without affecting the width that the qt layers calculates. I pull the desired value from option.decorationSize.
For this to work I had to add two lines of code in TQtWSCustomListView.setViewStyle that sets the size to ImageList.size for vsList and vsReport (similar to vsIcon and vsSmallIcon). I believe this is consistent with intent i.e. if an ImageList is assigned then that should be the desired height not QStylePM_ListViewIconsize.
If that is not true then the same thing could be done ItemDelegatesizeHint by querying the LCLObject for an appropriate ImageList and grabbing the height from there.
I also noticed that when QVariant_create() was called, if a invalid value was desired that it was created with QVariant_create(QVariantInvalid). QVariantInvalid is uint zero ('0') which means that a QVariant of type Uint is created with value '0' and if the QVariant.isValid() returns TRUE. I belive the proper method is 'bob = QVariant_create()'. I've included these changes in the attached diff.
Mantis conversion info:
- Mantis ID: 28212
- OS: Linux
- Platform: Qt
- Version: 1.4
- Fixed in revision: 49362 (#0a8fd259)