Qt5 Run task in background - c++11

I'm working on a Qt5 application where I need to perform some tasks asynchronously. I need something similar to dispatch_async in Objective-C. How could I achieve that?

Qt provides QtConcurrent::run
C++11 provides std::async

Related

macOS: rendering to another process' window

I have a Qt application that needs to be used from a VST plugin. However embedding a Qt application into a plugin seems like an incredibly complex task (because of the QCoreApplication event loop, because the host might also use a conflicting version of Qt, and because the plugin needs to find its own set of Qt libraries).
As a workaround I'd like to render my standalone Qt application to the VST plugin's window (for which I know the HWND/NSView).
It's easy to do on Windows, but a little more tricky on macOS.
tldr: I've read about NSWindowSharingType / NSWindowSharingReadWrite which seems to offer what I need on macOS (rendering a process' window into another process' window), but I can't find any example using that.
Does anybody know about that and how to use it ? Or any other way that would allow me to render my Qt widgets into a NSView from a different process ?
The solutions for this are quite nominal:
Your copy of Qt must be put into its own unique namespace - i.e. you have to build your own Qt. In a professional setting you're supposed to be doing this anyway.
The QCoreApplication event loop is fully integrated with NSRunLoop. You don't need to call exec() other than to prime the event loop: i.e. quit the event loop as soon as it is started, and let the host application do the rest. The idiom for this is:
QTimer::singleShot(0, app, &QCoreApplication::quit);
app->exec();
// return to the host app here
The plugin can and should bundle its own Qt, either as a bundled framework, or through static linking.
You can also pass an NSView* to QWindow::fromWinID, IIRC.

Is it possible to use haxe to build mac native application?

I see Haxe can compile to many languages, but not sure is it possible to use it build a native mac(OSX) application? Like a small TODO list application?
Yes, using OpenFL or other framework (Luxe, Kha, NME) you could target Mac and get project that compiles via XCode into native application.
If you want native OSX UI then there are libraries for that, such as Basis: https://github.com/Randonee/Basis. When using that you use the C++ target, and the library communicates with Objective C UI stuff via the C Foreign Function Interface. This comes with some limitations and depending on the status of the library, it could be hard to get started.
If you don't care about native UI then there are libraries that have what you need for simple notepad-type apps. In most cases you would still be able to use the C++ target. For example see Ian Harrigan's Haxe UI project: https://github.com/ianharrigan/haxeui

Attaching a plugins gui to the hosts gui

I'm writing an application with plugin support. I use C++ and JUCE for that stuff and I want my application to run on windows and MAC OSX (and maybe linux some day).
My plugins have their own GUI. The usual way to display a GUI from a shared library seems to be :
create a new window
get the native handle for it
pass it on to the library
let the library attach its GUI to that handle.
AFAIK that always requires to create a new window for the plugins GUI. My problem is: I would like to have the GUI of the plugins to appear inside the GUI of my host application (= not as a separate window).
I think this is a common thing to do, but I just can't find any concepts for that. How would you solve such a problem?
Thank you very much for ideas and hints!

How to access to native code in Air Application?

Hi I am working in a c++ program in win OS. Currently, by a constraint, I need to build an Air app that's hat to consume an api from by c++ program. I am being reading about how to access and I got Air Native Extension as "unique" approach consume dll.
by Chance, is there any other approach to way to consume an C++ api or maybe dll?
I found something that will probably help you.
You can communicate with native processes as if it were through a command line.
This should help:
http://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b060d22f991220f00ad8a-8000.html
Oh and this:
http://help.adobe.com/en_US/air/build/WS789ea67d3e73a8b22388411123785d839c-8000.html

Using WINAPI in Qt applications

Can anybody tell if I can use the Windows APIs in my qt application?
If yes can anybody tell me the procedure to do it? I need to use the msdn winapi "GetSystemPowerStatus" in my qt application to show the battery status in my qt GUI based application.
Yes, you can use those APIs (generally speaking), by including the appropriate header files.
It will make your code platform-specific (non-portable), so if there is a cross-platform way of doing so, I would use that.

Resources