diff --git a/lcl/interfaces/qt5/qtwsstdctrls.pp b/lcl/interfaces/qt5/qtwsstdctrls.pp index a1c6a1e3b4..040526d461 100644 --- a/lcl/interfaces/qt5/qtwsstdctrls.pp +++ b/lcl/interfaces/qt5/qtwsstdctrls.pp @@ -580,8 +580,17 @@ end; Returns: Nothing ------------------------------------------------------------------------------} class function TQtWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer; +var + QtListWidget: TQtListWidget; + AQtPoint: TQtPoint; begin Result := 0; + if not WSCheckHandleAllocated(ACustomListBox, 'GetTopIndex') then + Exit; + QtListWidget := TQtListWidget(ACustomListBox.Handle); + AQtPoint.x := 0; + AQtPoint.y := 0; + Result := QtListWidget.IndexAt(@AQtPoint); end; {------------------------------------------------------------------------------ diff --git a/lcl/interfaces/qt6/qtwsstdctrls.pp b/lcl/interfaces/qt6/qtwsstdctrls.pp index 9aec958dd1..7c2a59806a 100644 --- a/lcl/interfaces/qt6/qtwsstdctrls.pp +++ b/lcl/interfaces/qt6/qtwsstdctrls.pp @@ -580,8 +580,17 @@ end; Returns: Nothing ------------------------------------------------------------------------------} class function TQtWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer; +var + QtListWidget: TQtListWidget; + AQtPoint: TQtPoint; begin Result := 0; + if not WSCheckHandleAllocated(ACustomListBox, 'GetTopIndex') then + Exit; + QtListWidget := TQtListWidget(ACustomListBox.Handle); + AQtPoint.x := 0; + AQtPoint.y := 0; + Result := QtListWidget.IndexAt(@AQtPoint); end; {------------------------------------------------------------------------------