Hi,
I want to include a control in a TEdit. On Windows can decrease the editor rectangle with EM_SETRECT message. Any similar feature is exist in Qt or a multi platform solution?
Gabor

Mailing lists / lazarus / 2015-02
6 messages · 2 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
I want to include a control in a TEdit. On Windows can decrease the editor rectangle with EM_SETRECT message. Any similar feature is exist in Qt or a multi platform solution?
Gabor
In Qt yes, others like gtk2 no.
I've created and edit with button inside and it works (qt).
This should work:
EditBitBtn := TBitBtn.Create(Self{TMyEdit})
EditBitBtn.Height := Height - 4;
EditBitBtn.Width := 32; {eg TMyEdit width is 100}
EditBitBtn.Align := alRight;
EditBitBtn.Parent := Self;
EditBitBtn.Visible := True;
Only thing you should check in ComponentState or ControlStyle (cannot
remember now), that maybe you should add to TMyEdit (in constructor)
that it allows child controls ...zeljko
Sure, I've shown you howto do it under pure LCL with Qt widgetset, now you should include qtwidgets in your code and handle textrect when clientsize of TEdit is changed (button is shown or hidden).You can do that by setting: TQtLineEdit(Handle).TextMargins := SomeRect; Happy coding.
z.
It should look like this:
procedure TMyEdit.UpdateEditRect;
{$IFDEF LCLQt}
var
R: TRect;
{$ENDIF}
begin
if not HandleAllocated then
exit;
{$IFDEF LCLQt}
if FButtonVisible then
R := Rect(0, 0, FSB.Width, 0)
else
R := Rect(0, 0, 0, 0);
TQtLineEdit(Handle).TextMargins := R;
{$ENDIF}
end;And it should be changed in FontChanged, Resize, button visible/true/false etc ... FSB.Width = YOurButton.Width
z.
2015.02.02. 15:13 keltez?ssel, zeljko ?rta:
Works like a charm! Thank you very much Zeljko!
Gabor
Sure, I've shown you howto do it under pure LCL with Qt widgetset, now you should include…
2015.02.02. 15:11 keltez?ssel, zeljko ?rta:
I am happy and coding... :-)
Thank You again!
Gabor