开发者

Mac OS X linker error in Qt; CoreGraphics & CGWindowListCreate

Here is my .mm file

#inclu开发者_JAVA技巧de "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

The linker is telling me "_CGWindowListCreate" is undefined. What libraries must I link to? Apple's documentation is not very helpful on telling what to include or link to, like MSDN is. Also I couldn't just do #import <CGWindow.h>, I had to specify the absolute path to it... any way around that?


The CGWindowListCreate function is part of the Quartz Window Services. The corresponding framework is ApplicationServices which is located under /System/Library/Frameworks/.

So, you can just include <ApplicationServices/ApplicationServices.h> at the top of the file and link with the -framework ApplicationServicesoption.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜