diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 2aae5744fd..120f6a2f91 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -911,6 +911,7 @@ type TQtListWidget = class(TQtListView) private + FCheckable: boolean; FCurrentItemChangeHook: QListWidget_hookH; FSelectionChangeHook: QListWidget_hookH; FItemClickedHook: QListWidget_hookH; @@ -940,6 +941,7 @@ type procedure scrollToItem(row: integer; hint: QAbstractItemViewScrollHint); procedure removeItem(AIndex: Integer); procedure exchangeItems(AIndex1, AIndex2: Integer); + property Checkable: boolean read FCheckable write FCheckable; end; { TQtHeaderView } @@ -7061,6 +7063,7 @@ end; function TQtListWidget.CreateWidget(const AParams: TCreateParams): QWidgetH; begin + FCheckable := False; FDontPassSelChange := False; Result := QListWidget_create(); QWidget_setAttribute(Result, QtWA_NoMousePropagation); @@ -7125,7 +7128,7 @@ begin QEventMouseButtonRelease, QEventMouseButtonDblClick: begin - if (LCLObject.ClassType = TCheckListBox) and + if (Checkable) and (QEvent_type(Event) <> QEventMouseButtonDblClick) and (QMouseEvent_button(QMouseEventH(Event)) = QtLeftButton) then begin @@ -7212,7 +7215,7 @@ begin {$ifdef VerboseQt} WriteLn('TQtListWidget.signalItemClicked'); {$endif} - if LCLObject.ClassType = TCheckListBox then + if Checkable then begin FillChar(Msg, SizeOf(Msg), #0); Msg.Msg := LM_CHANGED; diff --git a/lcl/interfaces/qt/qtwschecklst.pp b/lcl/interfaces/qt/qtwschecklst.pp index f0ceca1f2d..1d457ca1c5 100644 --- a/lcl/interfaces/qt/qtwschecklst.pp +++ b/lcl/interfaces/qt/qtwschecklst.pp @@ -45,6 +45,8 @@ type TQtWSCustomCheckListBox = class(TWSCustomCheckListBox) published + class function CreateHandle(const AWinControl: TWinControl; + const AParams: TCreateParams): TLCLIntfHandle; override; class function GetItemEnabled(const ACheckListBox: TCustomCheckListBox; const AIndex: integer): Boolean; override; class function GetState(const ACheckListBox: TCustomCheckListBox; @@ -73,6 +75,37 @@ const {QtChecked } cbChecked ); +class function TQtWSCustomCheckListBox.CreateHandle( + const AWinControl: TWinControl; const AParams: TCreateParams + ): TLCLIntfHandle; +var + QtListWidget: TQtListWidget; + SelMode: QAbstractItemViewSelectionMode; +begin + QtListWidget := TQtListWidget.Create(AWinControl, AParams); + + QtListWidget.Checkable := True; + + if TCheckListBox(AWinControl).MultiSelect then + if TCheckListBox(AWinControl).ExtendedSelect then + SelMode := QAbstractItemViewExtendedSelection + else + SelMode := QAbstractItemViewMultiSelection + else + SelMode := QAbstractItemViewSingleSelection; + + QtListWidget.setSelectionMode(SelMode); + + QtListWidget.AttachEvents; + + // create our FList helper + QtListWidget.FList := TQtListStrings.Create(QtListWidget); + + QtListWidget.OwnerDrawn := TCheckListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable]; + + Result := TLCLIntfHandle(QtListWidget); +end; + class function TQtWSCustomCheckListBox.GetItemEnabled( const ACheckListBox: TCustomCheckListBox; const AIndex: integer): Boolean; var