简体   繁体   English

如何设置OpenCV和Qt的链接以使用createButton?

[英]How to setup linkage for OpenCV and Qt to use createButton?

I'm looking at opencv highgui samples (like connectedcomponents.cpp) and trying to get used to adding GUI elements. 我正在查看opencv highgui示例(如connectedcomponents.cpp),并试图习惯于添加GUI元素。 Currently I'm trying to add a button: 目前,我正在尝试添加一个按钮:

void on_button(int, void*){
    cout << "click" << end;
}
//in main()
createButton("test",on_button);

but I get a link error: 但我得到一个链接错误:

g++ -c -pipe -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_CORE_LIB -I../../../QtSDK/Desktop/Qt/474/gcc/mkspecs/macx-g++ -I. -I../../../QtSDK/Desktop/Qt/474/gcc/lib/QtCore.framework/Versions/4/Headers -I../../../QtSDK/Desktop/Qt/474/gcc/include/QtCore -I../../../QtSDK/Desktop/Qt/474/gcc/include -I/opt/local/include -I../../../QtSDK/Desktop/Qt/474/gcc/include -I. -F/Users/george/QtSDK/Desktop/Qt/474/gcc/lib -o main.o main.cpp
g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o CVConnectedComponent main.o   -F/Users/george/QtSDK/Desktop/Qt/474/gcc/lib -L/Users/george/QtSDK/Desktop/Qt/474/gcc/lib /opt/local/lib/libopencv_core.dylib /opt/local/lib/libopencv_contrib.dylib /opt/local/lib/libopencv_highgui.dylib /opt/local/lib/libopencv_objdetect.dylib /opt/local/lib/libopencv_imgproc.dylib /opt/local/lib/libopencv_features2d.dylib /opt/local/lib/libopencv_video.dylib -framework QtCore -F/Users/george/Documents/Qt/CVConnectedComponent/../../../QtSDK/Desktop/Qt/474/gcc/lib/ 
Undefined symbols:
  "cv::createButton(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void (*)(int, void*), void*, int, bool)", referenced from:
      _main in main.o
make: Leaving directory `/Users/george/Documents/Qt/CVConnectedComponent'
ld: symbol(s) not found

As far as I can understand I'm not linking against the QtCore library properly. 据我了解,我没有正确地链接到QtCore库。 I've this: 我有这个:

mac: LIBS += -framework QtCore

and this: 和这个:

mac: LIBS += -F$$PWD/../../../QtSDK/Desktop/Qt/474/gcc/lib/ -framework QtCore

INCLUDEPATH += $$PWD/../../../QtSDK/Desktop/Qt/474/gcc/include
DEPENDPATH += $$PWD/../../../QtSDK/Desktop/Qt/474/gcc/include

In the .pro file of the Qt project, but with no luck. 在Qt项目的.pro文件中,但是没有运气。 I'm using OpenCV 2.4.1 with Qt 4.7.4 on osx 10.6.8. 我在osx 10.6.8上使用带有Qt 4.7.4的OpenCV 2.4.1。

What's the correct way to link to QtCore in Qt Creator to use createButton in OpenCV ? 链接到Qt Creator中的QtCore以在OpenCV中使用createButton的正确方法是什么?

I've reinstalled OpenCV, this time with Qt support and the code worked. 我已经重新安装了OpenCV,这次得到了Qt支持,并且代码可以正常工作。 Still it's worth remembering that buttons will go into the Control Panel by default, as I found out by reading some documentation : 仍然值得记住的是,默认情况下,按钮会进入“控制面板”,正如我通过阅读一些文档发现的那样:

OpenCV Qt GUI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM