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:
zeljko 2010-07-01 13:46:43 +00:00
parent f4aff160db
commit d74087e32a
2 changed files with 17 additions and 3 deletions

View File

@ -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,

View File

@ -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;