diff --git a/lcl/interfaces/qt/qtcaret.pas b/lcl/interfaces/qt/qtcaret.pas index 877c69c65e..f57208cd90 100644 --- a/lcl/interfaces/qt/qtcaret.pas +++ b/lcl/interfaces/qt/qtcaret.pas @@ -43,6 +43,9 @@ uses LCLType, LCLIntf, Graphics, ExtCtrls; type + + { TEmulatedCaret } + TEmulatedCaret = class(TComponent) private FTimer: TTimer; @@ -60,6 +63,7 @@ type procedure DrawCaret; virtual; function CreateColorPixmap(Color: Cardinal): QPixmapH; procedure SetWidget(AWidget: TQtWidget); + procedure UpdateCaret; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -322,7 +326,10 @@ function TEmulatedCaret.Hide: Boolean; begin Result := IsValid; if Result and FVisible then + begin FVisible := False; + UpdateCaret; + end; end; procedure TEmulatedCaret.SetPos(const Value: TQtPoint); @@ -343,8 +350,8 @@ end; procedure TEmulatedCaret.DoTimer(Sender: TObject); begin FVisibleState := not FVisibleState; - if FVisible and (FWidget <> nil) and not FWidget.InPaint then - FWidget.Update; + if FVisible then + UpdateCaret; end; procedure TEmulatedCaret.Lock; @@ -403,4 +410,18 @@ begin FWndId := 0; end; +procedure TEmulatedCaret.UpdateCaret; +var + R: TRect; +begin + if (FWidget <> nil) and not FWidget.InPaint then + begin + R.Left := FPos.x; + R.Top := FPos.y; + R.Right := R.Left + FWidth; + R.Bottom := R.Top + FHeight; + FWidget.Update(@R); + end; +end; + end. diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index bf1bc5a489..8015d6db7c 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -108,8 +108,8 @@ type procedure SetColor(const Value: PQColor); virtual; procedure SetTextColor(const Value: PQColor); virtual; procedure SetCursor(const ACursor: QCursorH); virtual; - procedure Update; - procedure Repaint; + procedure Update(ARect: PRect = nil); + procedure Repaint(ARect: PRect = nil); procedure setWindowTitle(Str: PWideString); procedure WindowTitle(Str: PWideString); procedure Hide; @@ -1544,9 +1544,12 @@ end; Schedules a paint event for processing when Qt returns to the main event loop ------------------------------------------------------------------------------} -procedure TQtWidget.Update; +procedure TQtWidget.Update(ARect: PRect = nil); begin - QWidget_update(Widget); + if ARect <> nil then + QWidget_update(Widget, ARect) + else + QWidget_update(Widget); end; {------------------------------------------------------------------------------ @@ -1558,7 +1561,10 @@ end; ------------------------------------------------------------------------------} procedure TQtWidget.Repaint; begin - QWidget_repaint(Widget); + if ARect <> nil then + QWidget_repaint(Widget, ARect) + else + QWidget_repaint(Widget); end; procedure TQtWidget.setWindowTitle(Str: PWideString); diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 84ffc32d3d..f623ff4027 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -2763,7 +2763,7 @@ begin WriteLn('[WinAPI Invalidate Rect]'); {$endif} - QWidget_update(TQtWidget(aHandle).Widget,Rect); + TQtWidget(aHandle).Update(Rect); Result := True; end; @@ -3950,7 +3950,7 @@ begin {$ifdef VerboseQtWinAPI} WriteLn('[WinAPI UpdateWindow]'); {$endif} - QWidget_update(TQtWidget(Handle).Widget); + TQtWidget(Handle).Update; Result := True; end;