Qt Widget In Designer but still getting errors - c++

I have made a custom widget + plugin and implemented it into my Qt Designer. From there I then linked the *.lib file into my test application. Error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall GLineEdit::GLineEdit(class QWidget *)" (??0GLineEdit##QAE#PAVQWidget###Z) referenced in function "public: void __thiscall Ui_MainWindow::setupUi(class QMainWindow *)" (?setupUi#Ui_MainWindow##QAEXPAVQMainWindow###Z)
which doesnt make much sense as I have the correct includes in my the setupUi() function. Here is the relevant source code of the projects:
Widget Project
Plugin Project
Temporary Project

Related

linkage of qt objects in cmake

I have a library VMSCore which has VMSObject::public QObject.
I implemented factory class which inherit from VMSObject class.
After I built my library, I try to link it to my exe project.
I get linkage error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: virtual int __cdecl
VMS::Factory::qt_metacall(enum QMetaObject::Call,int,void * *)"
(?qt_metacall#Factory#VMS##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
referenced in function "public: virtual int __cdecl
VMS::Algorithm::Factory::qt_metacall(enum QMetaObject::Call,int,void *
*)" (?qt_metacall#Factory#Algorithm#VMS##UEAAHW4Call#QMetaObject##HPEAPEAX#Z) CVFnVMSExperimental C:\Users\Matvey\cvfn\build\Products\CVFnVMS\mocs_compilation.obj 1
As far as I understand the error, I don't link functions defined in moc files.
What is a right way to link moc-created files in CMake?
Solved.
I had to "set (CMAKE_AUTOMOC ON)" in my cmake file for library.

QML Rectangle as an Icon for a toolbox in Qt

I have designed an Image using Rectangle in QML in the Qt platform. I would like to take this QML file and add it on to my other Project in Visual Studio with Qt.
I have added my QML file in the resources of my Qt project in Visual Studio and have used the following code but gives me several external unresolved errors.
QQuickView *view = new QQuickView();
view->setSource(QUrl("main.qml"));
I would be glad if someone could help me out in using this QML Image as an Icon to the toolBox.
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport)
public: __cdecl QQuickView::QQuickView(class QWindow *)"
(__imp_??0QQuickView##QEAA#PEAVQWindow###Z) referenced in function
"public: __cdecl QtGuiApplication1::QtGuiApplication1(class QWidget
*)" (??0QtGuiApplication1##QEAA#PEAVQWidget###Z) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio
n1\QtGuiApplication1.obj 1 Error LNK2019 unresolved external symbol
"__declspec(dllimport) public: virtual __cdecl
QQuickView::~QQuickView(void)" (__imp_??1QQuickView##UEAA#XZ)
referenced in function "public: virtual void * __cdecl
QQuickView::`scalar deleting destructor'(unsigned int)"
(??_GQQuickView##UEAAPEAXI#Z) QtGuiApplication1
C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio
n1\QtGuiApplication1.obj 1 Error LNK2019 unresolved external symbol
"__declspec(dllimport) public: void __cdecl
QQuickView::setSource(class QUrl const &)"
(__imp_?setSource#QQuickView##QEAAXAEBVQUrl###Z) referenced in
function "public: __cdecl QtGuiApplication1::QtGuiApplication1(class
QWidget *)"
(??0QtGuiApplication1##QEAA#PEAVQWidget###Z) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio
n1\QtGuiApplication1.obj 1 Error LNK2001 unresolved external symbol
"public: virtual class QAccessibleInterface * __cdecl
QQuickWindow::accessibleRoot(void)const "
(?accessibleRoot#QQuickWindow##UEBAPEAVQAccessible
Interface##XZ) QtGuiApplication1 C:\Users\Desktop\QtGuiApplication1\QtGuiApplicatio
n1\QtGuiApplication1.obj 1
I am using Visual Studio with Qt and I think I need not add anything to .pro file.

XDispatch C++ Unresolved Externals

I'm work with GCD in C++ with xdisptach, libdispatch in Visual Studio 2012 on Windows 7.
I am declaring a class with a global variable that is a dispatch queue. Other functions in the class call the queue's function. Everything compiles fine, except when i instantiate the queue in the constructor.
xdispatch::queue* dispatch_queue;
AsyncNode()
{
dispatch_queue = new xdispatch::queue(Name);
}
When dispatch_queue = new xdispatch::queue(Name); is commented out, it all compiles fine. Otherwise i get the following errors.
Error 50 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall xdispatch::queue::~queue(void)" (__imp_??1queue#xdispatch##UAE#XZ) referenced in function "public: virtual void * __thiscall xdispatch::queue::`scalar deleting destructor'(unsigned int)" (??_Gqueue#xdispatch##UAEPAXI#Z)
Error 49 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall xdispatch::queue::queue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0queue#xdispatch##QAE#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z) referenced in function "public: __thiscall AsyncNode::AsyncNode(void)" (??0AsyncNode##QAE#XZ)
Error 53 error LNK2001: unresolved external symbol "public: virtual void __thiscall xdispatch::object::resume(void)" (?resume#object#xdispatch##UAEXXZ)
Error 51 error LNK2001: unresolved external symbol "public: virtual void * __thiscall xdispatch::queue::native(void)const " (?native#queue#xdispatch##UBEPAXXZ)
Error 52 error LNK2001: unresolved external symbol "public: virtual struct dispatch_queue_s * __thiscall xdispatch::queue::native_queue(void)const " (?native_queue#queue#xdispatch##UBEPAUdispatch_queue_s##XZ)
This is the main site for xdispatch, but i can't find anything in terms of a forum or help with xdispatch in particular. There are many for objective-c.... :/
http://opensource.mlba-team.de/xdispatch/docs/current/index.html
First of all, the behavior regarding deleting the "problematic" line is normal - when you're defining a pointer you're not invoking any function, and that is the reason you are not getting the "unresolved external errors".
When you're initializing the variable by calling the constructor, you then run into problems because you're trying to call a function which is not available at link time.
When working with external libraries using DLLs, you must link to the appropriate import libraries, usually supplied as "lib" files. In your case, there is a folder named "lib" in the zip package. Also, the DLLs must availble at run-time - by putting them in the folder of the executable, or adding them to the PATH environment variable.
In order to link to a library, follow these steps (taken from MSDN):
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the Linker folder.
Click the Input property page.
Modify the Additional Dependencies property.

How to use class from a different project in C++ with Qt?

There's this class MailHandler in the solution MailTest, which I use to send signals to the class MailCom in the solution MailResponse. My problem revolves around creating an object of the MailHandler class in the MailCom class, which is in a different project, and doing operations from here. What is the most efficient way of establishing the connection without modifying the MailTest project into a lib or DLL?
I need to link with a correct path, but I'm not sure at which settings are important in this case. This is the current error I'm getting when trying to instantiate the MailHandler object:
1> Creating library ..\..\bin\pvc6d.lib and object ..\..\bin\pvc6d.exp
1>CMailCom.obj : error LNK2019: unresolved external symbol "public: class QStringList __thiscall MailHandler::ReturnAllFunctions(void)" (?ReturnAllFunctions#MailHandler##QAE?AVQStringList##XZ) referenced in function "public: __thiscall pvc::hardwarecom::CMailCom::CMailCom(class pvc::data::CData &,class pvc::data::CRudderServo *,class pvc::data::CPropulsionManager *,class QGraphicsScene *)" (??0CMailCom#hardwarecom#pvc##QAE#AAVCData#data#2#PAVCRudderServo#42#PAVCPropulsionManager#42#PAVQGraphicsScene###Z)
1>CMailCom.obj : error LNK2019: unresolved external symbol "public: __thiscall MailHandler::MailHandler(class QObject *)" (??0MailHandler##QAE#PAVQObject###Z) referenced in function "public: __thiscall pvc::hardwarecom::CMailCom::CMailCom(class pvc::data::CData &,class pvc::data::CRudderServo *,class pvc::data::CPropulsionManager *,class QGraphicsScene *)" (??0CMailCom#hardwarecom#pvc##QAE#AAVCData#data#2#PAVCRudderServo#42#PAVCPropulsionManager#42#PAVQGraphicsScene###Z)
1>..\..\bin\pvc6d.exe : fatal error LNK1120: 2 unresolved externals
If you want to use a class of a external project, you can try to #include its header file (MailHandler.h, MailHandler.hxx etc.). I assume thats what you did. Obviously there is also a according source file (MailHandler.cpp, MailHandler.cxx). You can try to add this file to your current project. If you are lucky it compiles and links and your unresolved externals go away. More likely the source file has other dependencies and does not compile/link right away.
This is rather a hack - not a robust long term solution.
It's better to copy the file with its dependencies into your project
It's best to extract the needed classes in a separate project (i.e creating a lib or dll) that your project and that the other solution 'MailTest' are using as a independent client.
You are missing the correct libraries. The linker does not know about the functions called, add LIBS += -Lpath/to/lib -lthelib to your pro file.

QCustomPlot linker

I would like to use the features of QCustomPlot to draw some results from my openCV projects.
I didn't find a way to include QCustomPlot to my Microsoft Visual Studio 2010. I have included or course the cpp and h file into my project. But, I think what is still missing for me is regarding its linker and the additional dependencies (.lib file)
1>moc_ex4.obj : error LNK2019: unresolved external symbol "public: void __thiscall ex4::plot_graphs(void)" (?plot_graphs#ex4##QAEXXZ) referenced in function "private: static void __cdecl ex4::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall#ex4##CAXPAVQObject##W4Call#QMetaObject##HPAPAX#Z)
1>C:\Users\310114602\Documents\Visual Studio 2010\Projects\ex4_120313\Win32\Debug\\ex4.exe : fatal error LNK1120: 1 unresolved externals
I searched for it but no results.
Where shall I download it?
It looks like you either didn't moc your cpp file or you simply forgot to compile and link against the moc generated .cpp file.