View Issue Details

IDProjectCategoryView StatusLast Update
0038393LazarusLCLpublic2021-04-04 16:27
ReporterDavid Assigned ToZeljan Rikalo  
Status feedbackResolutionopen 
Product Version2.1 (SVN) 
Summary0038393: ListView under Qt5 sets wrong SortIndicator
DescriptionWith ListView, its possible to preset small icons, Sort Indicators, showing direction of sort. However, when you set siDescending on Qt5 it shows a downward pointing icon, the same icon as is show if you set siAscending.

Both GTK2 and GTK set an upward pointing 'arrow' for siDescending.

Once set and through one toggle cycle, Qt5 List view shows the same directions as do GTK2 and GTK3.

(While it might be easy to argue that siDecending should point down, it conflicts with GTK2, GTK3 and Qt5's siAscending settings)

Steps To ReproducePlace a ListView on a form, configure for Qt5 widget set, sets some initial conditions in FormCreate -
    ListView1.AutoSortIndicator := True;
    ListView1.Column[0].SortIndicator := siDescending; // can be siDescending, siAscending or siNone
    ListView1.SortColumn := 0;
    ListView1.Column[0].Caption:= 'A nice list';
    ListView1.SortType:= stBoth;
    ListView1.ViewStyle:= vsReport;
    ListView1.ReadOnly := True;

And run it. Note that the triangle in the column header is pointing down, switching back to GTK2 will show triangle pointing up. Back in Qt5, replace the siDescending with siAscending and it also points down !

TagsNo tags attached.
Fixed in Revision
Attached Files



2021-01-24 12:25

reporter   ~0128552

And of course, you need to add a column using the Object Inspector before the demo will work ....




2021-01-24 12:45

reporter   ~0128554

This has not been one of my best days !

I have just discovered that what I am seeing is affected by the TListView.SortDirection setting. Why it only affects QT5 and not GTK2 and why it reveres siDescending but not siAscending is beyond me but thats the way it is. Its probably not really the way it should be but a very easy work around.

"If its possible you are going to manually set the SortIndicators and you are using Qt5, make sure you set SortDirection to sdDescending. Having it set to the default sdAscending somehow messes with the column Sort Indicators ...."

I'll put a note on the Wiki, this problem has cost me several hours to pin down, might help someone else.

I am not convinced this is a real problem, feel free to close it if you thinks its trivial.


Zeljan Rikalo

2021-03-01 12:31

developer   ~0129274

Please attach example project. This works here , hence , I've setted up TListView in designer, but in runtime everything works as expected.


2021-03-13 08:26

reporter   ~0129620

OK Zelijan, sorry I have taken so long to get back to you.
The attached project will demonstrate the following small table -

     Initial QT5 Direction GTK2 Direction
     siDescending Down Up
     siAscending Down Down

     'Initial' The setting as determined in line 67/68 of unit1.pas
     'Qt5 Direction' The direction the indicator points at startup in Qt5
     'GTK2 Direction' The direction the indicator points at startup in GTK2


2021-03-13 08:27

reporter   ~0129621

OK, this time I will attach the project ..... (131,587 bytes)

Zeljan Rikalo

2021-04-04 15:56

developer   ~0130078

It works if you set ListView1.SortDirection := sdDescending instead of ListView1.Column[].SortIndicator.
TListView1.Column[].SortIndicator does not work because handle for TListView isn't allocated yet. Don't know why it works for others,
maybe sortIndicator should be setted up when column is created.

Zeljan Rikalo

2021-04-04 16:27

developer   ~0130079

Don't know what about win32 but TListView implementation of sorting indicator is pretty messy.
When Column.SortIndicator is changed ListView.SortDirection isn't changed at all and vice versa, so in this case WS don't know what to choose.
Gtk2/Gtk3 only redraws control and uses LCL values for drawing, so must investigate what gtk2 is used for this scenario.
In any case this should be fixed inside LCL somehow IMO.

Issue History

Date Modified Username Field Change
2021-01-24 07:53 David New Issue
2021-01-24 12:25 David Note Added: 0128552
2021-01-24 12:45 David Note Added: 0128554
2021-02-01 22:58 Zeljan Rikalo Assigned To => Zeljan Rikalo
2021-02-01 22:58 Zeljan Rikalo Status new => assigned
2021-03-01 12:31 Zeljan Rikalo Status assigned => feedback
2021-03-01 12:31 Zeljan Rikalo LazTarget => -
2021-03-01 12:31 Zeljan Rikalo Note Added: 0129274
2021-03-13 08:26 David Note Added: 0129620
2021-03-13 08:26 David Status feedback => assigned
2021-03-13 08:27 David Note Added: 0129621
2021-03-13 08:27 David File Added:
2021-04-04 15:56 Zeljan Rikalo Status assigned => feedback
2021-04-04 15:56 Zeljan Rikalo Note Added: 0130078
2021-04-04 16:27 Zeljan Rikalo Note Added: 0130079