Recent

Author Topic: TListView with vsIcon weird behavior on Qt  (Read 4770 times)

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 136
TListView with vsIcon weird behavior on Qt
« on: November 25, 2021, 05:08:33 pm »
So, recently I playing with Snap API to display package icons in ListView, and the result is kinda mess.

The first method is I populate the items first get Icons later.
The code:
Code: Pascal  [Select][+][-]
  1. procedure TAppCentreForm.FormShow(Sender: TObject);
  2. var
  3.   i: integer;
  4.   item: TListItem;
  5. begin
  6.   IconIndex := 0;
  7.   PackageIcons.Clear;
  8.   AddDefaultIcon;
  9.  
  10.   for i := 0 to SnapPackages.PackageList.Count -1 do
  11.   begin
  12.     item := LvPackages.Items.Add;
  13.     item.Caption := SnapPackages.PackageList[i].title;
  14.   end;
  15.  
  16.   if SnapPackages.PackageList.Count > 0 then
  17.     GetPackageIcon;
  18. end;  
  19.  
And the result is in the first attachment, kinda messy.

Second, I try to add default icon first, then set ImageIndex with real icons later. I also shortened the item caption because it does makes the item height inconsistent.
Code: Pascal  [Select][+][-]
  1. procedure TAppCentreForm.FormShow(Sender: TObject);
  2. var
  3.   i: integer;
  4.   item: TListItem;
  5. begin
  6.   IconIndex := 0;
  7.   PackageIcons.Clear;
  8.   AddDefaultIcon;
  9.  
  10.   for i := 0 to SnapPackages.PackageList.Count -1 do
  11.   begin
  12.     item := LvPackages.Items.Add;
  13.     item.Caption := SnapPackages.PackageList[i].title;
  14.     // set default icon first here
  15.     item.ImageIndex := 0;
  16.   end;
  17.  
  18.   if SnapPackages.PackageList.Count > 0 then
  19.     GetPackageIcon;
  20. end;  
  21.  
The result is quite good but I the item width is not aligned. (in second attachment)
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

zeljko

  • Hero Member
  • *****
  • Posts: 1341
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TListView with vsIcon weird behavior on Qt
« Reply #1 on: December 06, 2021, 06:45:59 pm »
Please open an issue about it and attach example project which mimicks GetPackageIcon from your code so I'll take a look into before lazarus 2.2 is launched.

AFFRIZA 亜風実

  • Full Member
  • ***
  • Posts: 136
Re: TListView with vsIcon weird behavior on Qt
« Reply #2 on: December 11, 2021, 04:41:25 pm »
Please open an issue about it and attach example project which mimicks GetPackageIcon from your code so I'll take a look into before lazarus 2.2 is launched.
Thanks for the reply, sorry for my late reply. I just opened a new issue: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39511
Kyoukai Framework: https://github.com/afuriza/kyoukai_framework

Dukung kemerdekaan Donetsk dan Lugansk! Tidak membalas profil berbendera biru-kuning apalagi ber-Bandera.

 

TinyPortal © 2005-2018