Qt5,Qt6: Fixed QLineEdit behaviour and automatic selectAll() by Qt when control is focused.Related issue #10155 and issue #41562

(cherry picked from commit 91fbaca370)

Co-authored-by: zeljan1 <zeljko@holobit.hr>
This commit is contained in:
Željan Rikalo 2025-04-03 22:07:53 +02:00 committed by Željan Rikalo
parent 462cf19bbc
commit 22c2c19030
2 changed files with 12 additions and 2 deletions

View File

@ -107,6 +107,7 @@ type
TQtWidget = class(TQtObject, IUnknown)
private
FDefaultFocusReason: QtFocusReason;
FInResizeEvent: boolean;
FWidgetState: TQtWidgetStates;
FWidgetDefaultFont: TQtFont;
@ -319,6 +320,7 @@ type
nil): QPixmapH;
property ChildOfComplexWidget: TChildOfComplexWidget read FChildOfComplexWidget write FChildOfComplexWidget;
property Context: HDC read GetContext;
property DefaultFocusReason: QtFocusReason read FDefaultFocusReason write FDefaultFocusReason;
property HasCaret: Boolean read FHasCaret write SetHasCaret;
property HasPaint: Boolean read FHasPaint write FHasPaint;
property InResizeEvent: boolean read FInResizeEvent write FInResizeEvent;
@ -2161,6 +2163,7 @@ end;
procedure TQtWidget.InitializeWidget;
begin
FDefaultFocusReason := QtTabFocusReason;
FInResizeEvent := False;
// default states
FWidgetState := [];
@ -5164,7 +5167,7 @@ end;
procedure TQtWidget.setFocus;
begin
if getFocusPolicy <> QtNoFocus then
QWidget_setFocus(Widget, QtTabFocusReason) {issue #10155}
QWidget_setFocus(Widget, FDefaultFocusReason) {issue #10155}
else
QWidget_setFocus(Widget);
end;
@ -9768,6 +9771,7 @@ begin
FCachedSelectionLen := -1;
FIntValidator := nil;
FNumbersOnly := False;
FDefaultFocusReason := QtOtherFocusReason;
if AParams.WndParent <> 0 then
Parent := TQtWidget(AParams.WndParent).GetContainerWidget
else
@ -16484,6 +16488,7 @@ end;
procedure TQtMenu.InitializeWidget;
begin
FDefaultFocusReason := QtTabFocusReason;
FWidgetState := [];
ChildOfComplexWidget := ccwNone;
WidgetColorRole := QPaletteWindow;

View File

@ -107,6 +107,7 @@ type
TQtWidget = class(TQtObject, IUnknown)
private
FDefaultFocusReason: QtFocusReason;
FInResizeEvent: boolean;
FWidgetState: TQtWidgetStates;
FWidgetDefaultFont: TQtFont;
@ -316,6 +317,7 @@ type
nil): QPixmapH;
property ChildOfComplexWidget: TChildOfComplexWidget read FChildOfComplexWidget write FChildOfComplexWidget;
property Context: HDC read GetContext;
property DefaultFocusReason: QtFocusReason read FDefaultFocusReason write FDefaultFocusReason;
property HasCaret: Boolean read FHasCaret write SetHasCaret;
property HasPaint: Boolean read FHasPaint write FHasPaint;
property InResizeEvent: boolean read FInResizeEvent write FInResizeEvent;
@ -2158,6 +2160,7 @@ end;
procedure TQtWidget.InitializeWidget;
begin
FDefaultFocusReason := QtTabFocusReason;
FInResizeEvent := False;
// default states
FWidgetState := [];
@ -5168,7 +5171,7 @@ end;
procedure TQtWidget.setFocus;
begin
if getFocusPolicy <> QtNoFocus then
QWidget_setFocus(Widget, QtTabFocusReason) {issue #10155}
QWidget_setFocus(Widget, FDefaultFocusReason) {issue #10155}
else
QWidget_setFocus(Widget);
end;
@ -9724,6 +9727,7 @@ begin
FCachedSelectionLen := -1;
FIntValidator := nil;
FNumbersOnly := False;
FDefaultFocusReason := QtOtherFocusReason;
if AParams.WndParent <> 0 then
Parent := TQtWidget(AParams.WndParent).GetContainerWidget
else
@ -16394,6 +16398,7 @@ end;
procedure TQtMenu.InitializeWidget;
begin
FDefaultFocusReason := QtTabFocusReason;
FWidgetState := [];
ChildOfComplexWidget := ccwNone;
WidgetColorRole := QPaletteWindow;