Lazarus

Programming => Widgetset => QT => Topic started by: c600g on August 05, 2021, 09:27:33 pm

Title: Performance of Qt5 LCL TListBox
Post by: c600g on August 05, 2021, 09:27:33 pm
I've noticed that the performance difference when loading 5,000+ items into a Qt5 TListBox (lbOwnerDrawFixed) is significantly slower than a Gtk2 TListBox.

In C++ Qt5 development, I encountered a similar problem which was resolved by using the setUniformItemSizes(true) method of a QListWidget.

Does the Qt5 LCL widget set implement this method if the item sizes are uniform?
Title: Re: Performance of Qt5 LCL TListBox
Post by: c600g on August 06, 2021, 12:21:38 am
Did a bit of diving into the C bindings a QtWidgets units to see if I could work around the issue, and it seems as if I have found a work around for the performance issue.

Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLIntf
  3.   , LCLType
  4.   {$ifdef LCLQT5}
  5.   , QtWidgets
  6.   {$endif}
  7.   ...
  8.  
  9. procedure MakeQtListViewFast( lst : TListBox );
  10. {$ifdef LCLQT5}
  11. var
  12.   QtListView : TQtListView;
  13. {$endif}
  14. begin
  15.   {$ifdef LCLQT5}
  16.   QtListView := TQtListView( lst.Handle );
  17.   QtListView.setUniformItemSizes( true );
  18.   {$endif}
  19. end;
  20.  

Alan
Title: Re: Performance of Qt5 LCL TListBox
Post by: JuhaManninen on August 06, 2021, 08:07:25 am
Does the Qt5 LCL widget set implement this method if the item sizes are uniform?
It is called in TQtWSCustomComboBox.CreateHandle() and in TQtWSCustomComboBox.SetItemHeight().
You can study and debug the code and create patch to improve it.
I have no idea why setUniformItemSizes() is needed or what happens if you enable it always.
Title: Re: Performance of Qt5 LCL TListBox
Post by: c600g on August 06, 2021, 04:22:27 pm
It is called in TQtWSCustomComboBox.CreateHandle() and in TQtWSCustomComboBox.SetItemHeight().
You can study and debug the code and create patch to improve it.
I have no idea why setUniformItemSizes() is needed or what happens if you enable it always.

Thanks for the tip. It looks as if I would need to modify TQtWSCustomListBox in lcl/interfaces/qt5/qtwsstdctrls.pp to do something similar for TListBox.
Title: Re: Performance of Qt5 LCL TListBox
Post by: JuhaManninen on August 07, 2021, 01:00:19 pm
It looks as if I would need to modify TQtWSCustomListBox in lcl/interfaces/qt5/qtwsstdctrls.pp to do something similar for TListBox.
Sorry, my answer was a bit sloppy. I just searched the sources for setUniformItemSizes.
The qt56.pas binding library has the function mapped only for ListView:
 QListView_setUniformItemSizes
It is used by TQtListWidget.
TQtWSCustomComboBox uses a TQtListWidget for its dropdown list.
TQtWSCustomListBox also uses a TQtListWidget. You should be able to improve it without any new function mappings. Yes.
TinyPortal © 2005-2018