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} {$DEFINE QTCOCOA}
{$ENDIF} {$ENDIF}
{$DEFINE QTSCROLLABLEFORMS} {$DEFINE QTSCROLLABLEFORMS}
{.$DEFINE QtUseNativeEventLoop}
{$IFDEF DARWIN} {$IFDEF DARWIN}
{enable this define if you have problems when dialogs are shown behind application} {enable this define if you have problems when dialogs are shown behind application}
{.$DEFINE TQTMESSAGEBOXUSEPARENT} {.$DEFINE TQTMESSAGEBOXUSEPARENT}

View File

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

View File

@ -78,6 +78,9 @@ begin
App := QApplicationH(QCoreApplication_instance()) App := QApplicationH(QCoreApplication_instance())
else else
App := QApplication_Create(@argc, argv); App := QApplication_Create(@argc, argv);
{$IFDEF QtUseNativeEventLoop}
FMainTimerID := -1;
{$ENDIF}
{$J+} {$J+}
QtVersionInt(QtVersionMajor, QtVersionMinor, QtVersionMicro); QtVersionInt(QtVersionMajor, QtVersionMinor, QtVersionMicro);
{$J-} {$J-}
@ -280,10 +283,22 @@ end;
Enter the main message loop Enter the main message loop
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TQtWidgetSet.AppRun(const ALoop: TApplicationMainLoop); procedure TQtWidgetSet.AppRun(const ALoop: TApplicationMainLoop);
{$IFDEF QtUseNativeEventLoop}
var
ATimer: QTimerH;
{$ENDIF}
begin 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 // use LCL loop
if Assigned(ALoop) then if Assigned(ALoop) then
ALoop; ALoop;
{$ENDIF}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -740,6 +755,14 @@ begin
end; end;
case QEvent_type(Event) of 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 QEventShortcutOverride: // issue #22827
begin begin
QKeyEvent_text(QKeyEventH(Event), @AKey); QKeyEvent_text(QKeyEventH(Event), @AKey);