唉,这是一个令人尴尬的愚蠢问题:
环境:Qt 5.1 Qt Creator 2.8 OSX 1.7.5;
如何通过 Qt Creator C++ 向导创建 QLabel 的子类?
具体来说,什么是base class
and type information
?我已经尝试了三种不同的方法,最终出现了各种编译错误(如下)。Qt 一直运行良好,所以看起来不像是安装问题,所以它一定是……用户问题。
回答:基类是 just QLabel
,类型信息是QWidget
显然我遇到了其他一些导致编译错误的问题。
如果我将类型信息设置为QWidget
或None
我收到错误
未找到体系结构 x86_64 的符号
如果我将类型信息设置为QObject
我收到错误:
从“QObject*”到“QWidget*”的无效转换
更新
01:25:29: Running steps for project LabelImageTest...
01:25:29: Configuration unchanged, skipping qmake step.
01:25:29: Starting: "/usr/bin/make"
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib -o mainwindow.o /Users/rise/QT_workspace/LabelImageTest/mainwindow.cpp
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib -o customlabel.o /Users/rise/QT_workspace/LabelImageTest/customlabel.cpp
/Users/rise/Qt/5.1.0/clang_64/bin/rcc -name images /Users/rise/QT_workspace/LabelImageTest/images.qrc -o qrc_images.cpp
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib -o qrc_images.o qrc_images.cpp
/Users/rise/Qt//5.1.0/clang_64/bin/moc -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D__APPLE__ -D__GNUC__=4 -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib /Users/rise/QT_workspace/LabelImageTest/mainwindow.h -o moc_mainwindow.cpp
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib -o moc_mainwindow.o moc_mainwindow.cpp
/Users/rise/Qt//5.1.0/clang_64/bin/moc -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -D__APPLE__ -D__GNUC__=4 -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib /Users/rise/QT_workspace/LabelImageTest/customlabel.h -o moc_customlabel.cpp
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/rise/Qt/5.1.0/clang_64/mkspecs/macx-g++ -I/Users/rise/QT_workspace/LabelImageTest -I/Users/rise/Qt/5.1.0/clang_64/include -I/Users/rise/Qt/5.1.0/clang_64/include/QtWidgets -I/Users/rise/Qt/5.1.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtGui -I/Users/rise/Qt/5.1.0/clang_64/lib/QtGui.framework/Headers -I/Users/rise/Qt/5.1.0/clang_64/include/QtCore -I/Users/rise/Qt/5.1.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/rise/Qt//5.1.0/clang_64/lib -o moc_customlabel.o moc_customlabel.cpp
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -o LabelImageTest.app/Contents/MacOS/LabelImageTest main.o mainwindow.o customlabel.o qrc_images.o moc_mainwindow.o moc_customlabel.o -F/Users/rise/Qt//5.1.0/clang_64/lib -framework QtWidgets -F/Users/rise/Qt//5.1.0/clang_64/qtbase/lib -framework QtGui -framework QtCore -framework OpenGL -framework AGL
ld: warning: directory not found for option '-F/Users/rise/Qt//5.1.0/clang_64/qtbase/lib'
Undefined symbols for architecture x86_64:
"MainWindow::on_label_linkActivated(QString const&)", referenced from:
MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)in moc_mainwindow.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [LabelImageTest.app/Contents/MacOS/LabelImageTest] Error 1
01:25:34: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project LabelImageTest (kit: QT 5.1)
When executing step 'Make'
01:25:34: Elapsed time: 00:05.