1
类QMacNativeWidget QT5文档中列出未定义的符号,但与嵌入式Qt控件创建Cocoa应用程序的任何企图给我一个错误:Qt5。 QMacNativeWidget。对于建筑x86_64的
Undefined symbols for architecture x86_64:
"QMacNativeWidget::QMacNativeWidget(void*)", referenced from:
-[AppDelegate loadUi] in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这里是我的代码:
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
std::auto_ptr<QWidget> nativeWidget;
...
}
// Qt Widget will be attached to this view
@property (weak) IBOutlet NSView *view;
@end
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self initQtIfNeeded];
[self loadUi];
}
-(void) initQtIfNeeded
{
QApplication* app = qApp;
if (app == 0)
{
puts("Creating new QApplication instance...");
QApplication::setDesktopSettingsAware(true);
QApplication::setAttribute(Qt::AA_MacPluginApplication, true);
int argc = 0;
app = new QApplication(argc, NULL);
...
}
}
-(void)loadUi
{
nativeWidget.reset(new QMacNativeWidget());
...
// Casting pointer (x86_64 with ARC)
void* winId = reinterpret_cast<void *>(nativeWidget->winId());
NSView *nativeWidgetNSView = (__bridge NSView*)winId;
// Attaching Qt Widget to NSView
[self.view addSubview:nativeWidgetNSView positioned:NSWindowAbove relativeTo:nil];
nativeWidget->setGeometry(0, 0, self.view.frame.size.width, self.view.frame.size.height);
...
nativeWidget->show();
}
当我使用QWidget而不是QMacNativeWidget(即:nativeWidget.reset(new QWidget());
)应用程序成功链接,但在运行时创建了额外的窗口(
我的问题:我做得不对,或者是Qt的问题? 谢谢!
你链接了哪些库? – 2013-02-12 06:47:47
使用这套库:'-lQt5Gui_debug -lQt5Core_debug -lQt5PlatformSupport_debug -lQt5PrintSupport_debug -lQt5Widgets_debug' – Vlad 2013-02-12 07:46:26
只需接收来自Digia的电子邮件。他们告诉我,'QMacNativeWidget'现在是独立包[QtMacExtras]的一部分(http://qt.gitorious.org/qtplayground/qtmacextras)。这个软件包稍后将成为Qt的一部分(计划在Qt 5.1中使用)。 Qt5中'QMacNativeWidget'的文档是由错误产生的,他们稍后会处理它。 – Vlad 2013-02-13 13:09:00