我想在Mac OS X上的Qt应用程序中使用NSRunningApplication
。
我尝试在mainwindow.cpp
中包含这些头文件:
#include Cocoa/Cocoa.h
#include Foundation/Foundation.h
#include AppKit/NSRunningApplication.h
#include AppKit/NSWorkspace.h
#include ApplicationServices/ApplicationServices.h
#include "CGWindow.h".
还包括.pro
文件
INCLUDEPATH += /System/Library/Frameworks/Foundation.framework/Headers
但这会产生错误:stray '@' in program
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6:
In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:6,
/System/Library/Frameworks/Foundation.framework/Headers/NSZone.h:8 : error: stray '@' in program.
我的问题是:
如何在我的申请中使用NSRunningApplication
?
要包含哪些文件以及删除这些错误的位置/方式?
答案 0 :(得分:1)
您需要制作一个objc文件。将扩展名更改为.mm并使用objc指令导入框架:
#import <Foundation/Foundation.h>