Qt5, Qt6: Fixed bug with TListView.LargeImages and vsIcon style. issue #39511

This commit is contained in:
Željan Rikalo 2024-11-19 19:44:34 +01:00
parent 2e1792430b
commit 4dc3c40696
2 changed files with 28 additions and 0 deletions

View File

@ -1582,6 +1582,8 @@ var
TWI: QTreeWidgetItemH;
Str: WideString;
AAlignment: QtAlignment;
ABmp: TBitmap;
AListItem: QListWidgetItemH;
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetText') then
Exit;
@ -1597,6 +1599,18 @@ begin
if (TCustomListViewHack(ALV).Columns.Count > 0) and (ASubIndex < TCustomListViewHack(ALV).Columns.Count) then
AAlignment := AlignmentToQtAlignmentMap[ALV.Column[ASubIndex].Alignment];
QtListWidget.setItemText(AIndex, AText, AAlignment);
if (TCustomListViewHack(ALV).ViewStyle = vsIcon) and (AItem.ImageIndex < 0) and
Assigned(TListView(ALV).LargeImages) then
begin
ABmp := TBitmap.Create;
ABmp.PixelFormat := pf32bit;
ABmp.SetSize(TListView(ALV).LargeImages.Width, TListView(ALV).LargeImages.Height);
ABmp.Canvas.Brush.Color := clNone;
ABmp.Canvas.FillRect(Rect(0, 0, ABmp.Width, ABmp.Height));
AListItem := QtListWidget.getItem(AIndex);
QListWidgetItem_setIcon(AListItem, TQtImage(ABmp.Handle).AsIcon);
ABmp.Free;
end;
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);

View File

@ -1579,6 +1579,8 @@ var
TWI: QTreeWidgetItemH;
Str: WideString;
AAlignment: QtAlignment;
ABmp: TBitmap;
AListItem: QListWidgetItemH;
begin
if not WSCheckHandleAllocated(ALV, 'ItemSetText') then
Exit;
@ -1594,6 +1596,18 @@ begin
if (TCustomListViewHack(ALV).Columns.Count > 0) and (ASubIndex < TCustomListViewHack(ALV).Columns.Count) then
AAlignment := AlignmentToQtAlignmentMap[ALV.Column[ASubIndex].Alignment];
QtListWidget.setItemText(AIndex, AText, AAlignment);
if (TCustomListViewHack(ALV).ViewStyle = vsIcon) and (AItem.ImageIndex < 0) and
Assigned(TListView(ALV).LargeImages) then
begin
ABmp := TBitmap.Create;
ABmp.PixelFormat := pf32bit;
ABmp.SetSize(TListView(ALV).LargeImages.Width, TListView(ALV).LargeImages.Height);
ABmp.Canvas.Brush.Color := clNone;
ABmp.Canvas.FillRect(Rect(0, 0, ABmp.Width, ABmp.Height));
AListItem := QtListWidget.getItem(AIndex);
QListWidgetItem_setIcon(AListItem, TQtImage(ABmp.Handle).AsIcon);
ABmp.Free;
end;
end else
begin
QtTreeWidget := TQtTreeWidget(ALV.Handle);