Qt: added ability to use native Qt event loop via define QtUseNativeEventLoop (qtdefines.inc)

git-svn-id: trunk@53021 -
This commit is contained in:
zeljko 2016-09-23 12:40:15 +00:00
parent e8ac80123b
commit b47f15b76e
3 changed files with 27 additions and 0 deletions

View File

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

View File

@ -50,6 +50,9 @@ type
TQtWidgetSet = Class(TWidgetSet)
private
App: QApplicationH;
{$IFDEF QtUseNativeEventLoop}
FMainTimerID: integer;
{$ENDIF}
{$IFDEF QtUseAccurateFrame}
FWSFrameMargins: TRect;
{$ENDIF}

View File

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