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