mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 12:38:15 +02:00
Qt: added ability to use native Qt event loop via define QtUseNativeEventLoop (qtdefines.inc)
git-svn-id: trunk@53021 -
This commit is contained in:
parent
e8ac80123b
commit
b47f15b76e
@ -9,6 +9,7 @@
|
||||
{$DEFINE QTCOCOA}
|
||||
{$ENDIF}
|
||||
{$DEFINE QTSCROLLABLEFORMS}
|
||||
{.$DEFINE QtUseNativeEventLoop}
|
||||
{$IFDEF DARWIN}
|
||||
{enable this define if you have problems when dialogs are shown behind application}
|
||||
{.$DEFINE TQTMESSAGEBOXUSEPARENT}
|
||||
|
@ -50,6 +50,9 @@ type
|
||||
TQtWidgetSet = Class(TWidgetSet)
|
||||
private
|
||||
App: QApplicationH;
|
||||
{$IFDEF QtUseNativeEventLoop}
|
||||
FMainTimerID: integer;
|
||||
{$ENDIF}
|
||||
{$IFDEF QtUseAccurateFrame}
|
||||
FWSFrameMargins: TRect;
|
||||
{$ENDIF}
|
||||
|
@ -78,6 +78,9 @@ begin
|
||||
App := QApplicationH(QCoreApplication_instance())
|
||||
else
|
||||
App := QApplication_Create(@argc, argv);
|
||||
{$IFDEF QtUseNativeEventLoop}
|
||||
FMainTimerID := -1;
|
||||
{$ENDIF}
|
||||
{$J+}
|
||||
QtVersionInt(QtVersionMajor, QtVersionMinor, QtVersionMicro);
|
||||
{$J-}
|
||||
@ -280,10 +283,22 @@ end;
|
||||
Enter the main message loop
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
|
||||
{$IFDEF QtUseNativeEventLoop}
|
||||
var
|
||||
ATimer: QTimerH;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF QtUseNativeEventLoop}
|
||||
ATimer := QTimer_create(QCoreApplication_instance());
|
||||
QTimer_setInterval(ATimer, 0);
|
||||
QTimer_start(ATimer);
|
||||
FMainTimerID := QTimer_timerId(ATimer);
|
||||
QApplication_exec();
|
||||
{$ELSE}
|
||||
// use LCL loop
|
||||
if Assigned(ALoop) then
|
||||
ALoop;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -740,6 +755,14 @@ begin
|
||||
end;
|
||||
|
||||
case QEvent_type(Event) of
|
||||
{$IFDEF QtUseNativeEventLoop}
|
||||
QEventTimer:
|
||||
begin
|
||||
if (QTimerEvent_timerId(QTimerEventH(Event)) = FMainTimerID) and
|
||||
Assigned(Application) and not Application.Terminated then
|
||||
Application.Idle(True);
|
||||
end;
|
||||
{$ENDIF}
|
||||
QEventShortcutOverride: // issue #22827
|
||||
begin
|
||||
QKeyEvent_text(QKeyEventH(Event), @AKey);
|
||||
|
Loading…
Reference in New Issue
Block a user