Discussion:
[Interest] Native windows with QtCore backend
Jeffrey Brendecke
2018-10-28 15:58:57 UTC
Permalink
Is it possible to have a 100% native UI (Cocoa or UIKit) with backend QtCore components (nonGUI) on a functioning event loop for signals and slots on macOS and iOS?

For example, I would like use the Qt network components to interact with a network while using only native windows and native views for the presentation.
Thiago Macieira
2018-10-28 19:23:02 UTC
Permalink
Post by Jeffrey Brendecke
Is it possible to have a 100% native UI (Cocoa or UIKit) with backend QtCore
components (nonGUI) on a functioning event loop for signals and slots on
macOS and iOS?
Sure. But you need to integrate the event loops, so one of these three things:

1) use the Core Foundation event dispatcher (and make sure it works)

2) tell your native UI event dispatcher to use QSocketNotifier and QTimer

3) write an event dispatcher deriving from QAbstractEventDispatcher that
integrates QSocketNotifier and QTimer with your native UI's dispatcher

The event dispatcher you really want is called QCocoaEventDispatcher, but it's
in the Cocoa QPA plugin, which requires QtGui.
Post by Jeffrey Brendecke
For example, I would like use the Qt network components to interact with a
network while using only native windows and native views for the
presentation.
Option 4: only use Qt components outside the main thread.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Jeffrey Brendecke
2018-10-29 14:24:25 UTC
Permalink
Post by Thiago Macieira
Post by Jeffrey Brendecke
Is it possible to have a 100% native UI (Cocoa or UIKit) with backend QtCore
components (nonGUI) on a functioning event loop for signals and slots on
macOS and iOS?
1) use the Core Foundation event dispatcher (and make sure it works)
2) tell your native UI event dispatcher to use QSocketNotifier and QTimer
3) write an event dispatcher deriving from QAbstractEventDispatcher that
integrates QSocketNotifier and QTimer with your native UI's dispatcher
The event dispatcher you really want is called QCocoaEventDispatcher, but it's
in the Cocoa QPA plugin, which requires QtGui.
Post by Jeffrey Brendecke
For example, I would like use the Qt network components to interact with a
network while using only native windows and native views for the
presentation.
Option 4: only use Qt components outside the main thread.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
-----

Thanks, Thiago,

Regarding: 1-3, I was afraid something like that would be the case after looking at the Qt-Mac integration code.

Option 4 looks like a possibility for me.

It looks like it means that as long as I run QCoreApplication::exec() on its own thread, that I can do all the Qt event handling/signal slot connections I want on that thread and not worry about what's going on on the main thread/Apple event loop until I need to synchronize data with the main thread. Then, it would be nothing more than what is normally involved with synchronizing data between threads.

Is this correct?

Thanks in advance,

Jeffrey
Thiago Macieira
2018-10-29 16:16:01 UTC
Permalink
Post by Jeffrey Brendecke
It looks like it means that as long as I run QCoreApplication::exec() on its
own thread, that I can do all the Qt event handling/signal slot connections
I want on that thread and not worry about what's going on on the main
thread/Apple event loop until I need to synchronize data with the main
thread. Then, it would be nothing more than what is normally involved with
synchronizing data between threads.
Is this correct?
Sounds about right. Just one detail: QCoreApplication::exec can only be called
in the main thread and Qt thinks the main thread is the one where the first
QObject was created, which is usually the QCoreApplication itself.

But you can use a QEventLoop in any thread. You still need to create a
QCoreApplication in the main thread, but you don't have to exec() it.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
黄其泽
2018-10-29 11:26:30 UTC
Permalink
The signal/slot mechanism does not always requires Qt eventloop. So, you
can use QtCore directly without any other works.

But QtNetwork requires eventloop to dispatch network IO events. You'd
better use other network toolkit then.

In fact, the signal/slot connection with Qt::QueuedConnection type do need
a eventloop, but it is used between threads mostly. You can choose
other mechanism
provided by native OS.

I am using QtCore alonely in server programs for several years. It is
proved to very reliable.
Post by Jeffrey Brendecke
Is it possible to have a 100% native UI (Cocoa or UIKit) with backend
QtCore components (nonGUI) on a functioning event loop for signals and
slots on macOS and iOS?
For example, I would like use the Qt network components to interact with a
network while using only native windows and native views for the
presentation.
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
--
Python及Qt盞关Bloghttp://hgoldfish.com/
Loading...