这是我的 .mm 文件
#include "windowmanagerutils.h"
#ifdef Q_OS_MAC
#import </System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Headers/CGWindow.h>
QRect WindowManagerUtils::getWindowRect(WId windowId)
{
CFArrayRef windows = CGWindowListCreate(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
return QRect();
}
QRect WindowManagerUtils::getClientRect(WId windowId)
{
return QRect();
}
QString WindowManagerUtils::getWindowText(WId windowId)
{
return QString();
}
WId WindowManagerUtils::rootWindow()
{
QApplication::desktop()->winId();
}
WId WindowManagerUtils::windowFromPoint(const QPoint &p, WId parent, bool(*filterFunction)(WId))
{
return NULL;
}
void WindowManagerUtils::setTopMostCarbon(const QWidget *const window, bool topMost)
{
if (!window)
{
return;
}
// Find a Cocoa equivalent for this Carbon function
// [DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
// OSStatus ret = HIViewSetZOrder(this->winId(), kHIViewZOrderAbove, NULL);
}
#endif
链接器告诉我“_CGWindowListCreate”未定义。我必须链接到哪些库?Apple 的文档对于告知要包含或链接的内容不是很有帮助,就像 MSDN 一样。我也不能这样做#import <CGWindow.h>
,我必须指定它的绝对路径......有什么办法吗?