Forum > QT
TListView with vsIcon weird behavior on Qt
(1/1)
AFFRIZA 亜風実:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TAppCentreForm.FormShow(Sender: TObject);var i: integer; item: TListItem;begin IconIndex := 0; PackageIcons.Clear; AddDefaultIcon; for i := 0 to SnapPackages.PackageList.Count -1 do begin item := LvPackages.Items.Add; item.Caption := SnapPackages.PackageList[i].title; end; if SnapPackages.PackageList.Count > 0 then GetPackageIcon;end; 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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TAppCentreForm.FormShow(Sender: TObject);var i: integer; item: TListItem;begin IconIndex := 0; PackageIcons.Clear; AddDefaultIcon; for i := 0 to SnapPackages.PackageList.Count -1 do begin item := LvPackages.Items.Add; item.Caption := SnapPackages.PackageList[i].title; // set default icon first here item.ImageIndex := 0; end; if SnapPackages.PackageList.Count > 0 then GetPackageIcon;end; The result is quite good but I the item width is not aligned. (in second attachment)
zeljko:
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 亜風実:
--- Quote from: zeljko 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.
--- End quote ---
Thanks for the reply, sorry for my late reply. I just opened a new issue: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39511
Navigation
[0] Message Index