K
K
kapitan0v2014-10-25 08:14:43
Cocoa
kapitan0v, 2014-10-25 08:14:43

How to use Cocoa in a Qt5 project?

Hello!
I'm writing an application for OS X using Qt5 which keeps track of application launches.
How to get a list of running applications figured out:

#import <Cocoa/Cocoa.h>

QList<CProcInfo> procList;
CProcInfo procInfo;
for(NSRunningApplication *app in NSWorkspace.sharedWorkspace.runningApplications)
{
    procInfo.pid = (quint32)app.processIdentifier;
    procInfo.name = QString::fromNSString(app.localizedName);
    procInfo.path = QString::fromNSString(app.executableURL.path);
    procList << procInfo;
}

I call this code once in a certain period of time. But I don't think this is correct. I found this notification in the Cocoa documentation: NSWorkspaceDidLaunchApplicationNotification .
Just could not figure out how to use it in a Qt application.
Well, one more question for backfilling, if I may.
Here:
NSRunningApplication *app
as far as I understand, memory is allocated, how to free it when the app object is no longer needed?
Thanks in advance for your replies!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question