diff --git a/lcl/interfaces/qt/qtwscontrols.pp b/lcl/interfaces/qt/qtwscontrols.pp index 9f4218bffe..e7164aa6f0 100644 --- a/lcl/interfaces/qt/qtwscontrols.pp +++ b/lcl/interfaces/qt/qtwscontrols.pp @@ -307,8 +307,9 @@ class procedure TQtWSWinControl.SetText(const AWinControl: TWinControl; begin if not WSCheckHandleAllocated(AWincontrol, 'SetText') then Exit; - + TQtWidget(AWinControl.Handle).BeginUpdate; TQtWidget(AWinControl.Handle).setText(GetUtf8String(AText)); + TQtWidget(AWinControl.Handle).EndUpdate; end; class procedure TQtWSWinControl.SetChildZPosition(const AWinControl, diff --git a/lcl/interfaces/qt/qtwsstdctrls.pp b/lcl/interfaces/qt/qtwsstdctrls.pp index 602ee3b628..0ed2f177e3 100644 --- a/lcl/interfaces/qt/qtwsstdctrls.pp +++ b/lcl/interfaces/qt/qtwsstdctrls.pp @@ -1165,15 +1165,28 @@ class function TQtWSCustomComboBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; var QtComboBox: TQtComboBox; + ItemIndex: Integer; + Text: String; begin QtComboBox := TQtComboBox.Create(AWinControl, AParams); - QtComboBox.AttachEvents; - QtComboBox.OwnerDrawn := TCustomComboBox(AWinControl).Style in [csOwnerDrawFixed, csOwnerDrawVariable]; // create our FList helper QtComboBox.FList := TQtComboStrings.Create(AWinControl, QtComboBox); QtComboBox.setMaxVisibleItems(TCustomComboBox(AWinControl).DropDownCount); + // load combo data imediatelly and set LCLs itemIndex and Text otherwise + // qt will set itemindex to 0 if lcl itemindex = -1. + ItemIndex := TCustomComboBox(AWinControl).ItemIndex; + Text := TCustomComboBox(AWinControl).Text; + QtComboBox.FList.Assign(TCustomComboBox(AWinControl).Items); + QtComboBox.setCurrentIndex(ItemIndex); + QtComboBox.setText(GetUTF8String(Text)); + QtComboBox.setEditable(AParams.Style and CBS_DROPDOWN <> 0); + + QtComboBox.AttachEvents; + QtComboBox.OwnerDrawn := (AParams.Style and CBS_OWNERDRAWFIXED <> 0) or + (AParams.Style and CBS_OWNERDRAWVARIABLE <> 0); + Result := TLCLIntfHandle(QtComboBox); end;