mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 18:40:29 +02:00
Qt: load TCustomComboBox data and params inside CreateHandle, so avoid qt to set itemindex on it's own. fixes #16727
git-svn-id: trunk@26389 -
This commit is contained in:
parent
f4aff160db
commit
d74087e32a
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user