Q_OBJECT is giving me this linking error - qt

I'm using qt and there's a problem here , when I include q_object it gives me these errors:
moc_finddialong.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl Finddialong::findClicked(void)" (?findClicked#Finddialong##AEAAXXZ) referenced in function "private: static void __cdecl Finddialong::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall#Finddialong##CAXPEAVQObject##W4Call#QMetaObject##HPEAPEAX#Z)
moc_finddialong.obj:-1: error: LNK2019: unresolved external symbol "private: void __cdecl Finddialong::enablefindButton(class QString const &)" (?enablefindButton#Finddialong##AEAAXAEBVQString###Z) referenced in function "private: static void __cdecl Finddialong::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall#Finddialong##CAXPEAVQObject##W4Call#QMetaObject##HPEAPEAX#Z)
debug\try.exe:-1: error: LNK1120: 2 unresolved externals
,,
when I delete it and run qmake and compile it , the problem goes away , but I need q_object since my class has slots and signals.
Tried:
1-clean the project " I even started a new one " + run qmake and rebuild it and it didn't work.
2- checked if the header is included in the pro file and it is included.
that's about every solution I found in google.
Help pls.

Related

LNK2001 problem (Follow-up to https://stackoverflow.com/questions/65643450/lnk2019-declspecdllimport-cdecl-issue)

Note: This is the second part of the problem I'm facing. The first part is here.
I'm not sure how I got to this problem, but the other part is these four:
main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl cm::controllers::MasterController::metaObject(void)const " (?metaObject#MasterController#controllers#cm##UEBAPEBUQMetaObject##XZ)
,
main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __cdecl cm::controllers::MasterController::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#MasterController#controllers#cm##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
,
main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __cdecl cm::controllers::MasterController::qt_metacast(char const *)" (?qt_metacast#MasterController#controllers#cm##UEAAPEAXPEBD#Z)
and finally,
main.obj:-1: error: LNK2001: unresolved external symbol "__declspec(dllimport) public: static struct QMetaObject const cm::controllers::MasterController::staticMetaObject" (__imp_?staticMetaObject#MasterController#controllers#cm##2UQMetaObject##B)
Something I found while searching on this was that I could get rid of all of these through removing Q_OBJECT, saving, then putting it back. For me, it only went away when I removed Q_OBJECT without putting it back. This definitely isn't a solution, just something interesting I found.
I'm using Qt Creator 5.12, by the way.

LNK errors on building opencv contrib cvv module

I am building opencv 4.3.0 in the windows-vs2015, using cmake3.17.3, with WITH_QT enabled. Here are errors messages related to opencv_contrib module cvv in the building process:
Creating library C:/opencv/opencv-4.3.0-cbuild/lib/Release/opencv_world430.lib and object C:/opencv/opencv-4.3.0-cbuild/lib/Release/opencv_world430.exp
view_controller.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl cvv::gui::CallTab::metaObject(void)const " (?metaObject#CallTab#gui#cvv##UEBAPEBUQMetaObject##XZ)
image_call_tab.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl cvv::gui::CallTab::metaObject(void)const " (?metaObject#CallTab#gui#cvv##UEBAPEBUQMetaObject##XZ)
view_controller.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl cvv::gui::CallTab::qt_metacast(char const *)" (?qt_metacast#CallTab#gui#cvv##UEAAPEAXPEBD#Z)
image_call_tab.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl cvv::gui::CallTab::qt_metacast(char const *)" (?qt_metacast#CallTab#gui#cvv##UEAAPEAXPEBD#Z)
view_controller.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cvv::gui::CallTab::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CallTab#gui#cvv##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
image_call_tab.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl cvv::gui::CallTab::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#CallTab#gui#cvv##UEAAHW4Call#QMetaObject##HPEAPEAX#Z)
view_controller.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject
.........
C:\opencv\opencv-4.3.0-cbuild\bin\Release\opencv_world430.dll : fatal error LNK1120: 226 unresolved externals
What is the problem with these errors? I googled online and found some similar posts (https://answers.opencv.org/question/210338/build-error-when-activating-both-cvv-and-world/; Linking errors for Qt and cvv when building OpenCV in Windows 10). It seems that BUILD_opencv_world, WITH_QT and Build_opencv_cvv cannot be activated simultaneously for building. Should I need to remove the cvv module from the opencv_contrib folder?

Unresolved external symbols in qtmaind.lib

I am trying to upgrade my Qt-project settings from Visual Studio 2013 to 2015. It almost done but I get some errors with qtmaind.lib.
1>qtmaind.lib(qtmain_winrt.obj) : error LNK2019: unresolved external
symbol imp__RoInitialize#4 referenced in function _WinMain#16
1>qtmaind.lib(qtmain_winrt.obj) : error LNK2019: unresolved external
symbol __imp__RoGetActivationFactory#12 referenced in function
"public: __thiscall AppContainer::AppContainer(void)"
(??0AppContainer##QAE#XZ) 1>qtmaind.lib(qtmain_winrt.obj) : error
LNK2019: unresolved external symbol _WindowsCreateStringReference#16
referenced in function "private: void __thiscall
Microsoft::WRL::Wrappers::HStringReference::CreateReference(wchar_t
const *,unsigned int,unsigned int)"
(?CreateReference#HStringReference#Wrappers#WRL#Microsoft##AAEXPB_WII#Z)
1>qtmaind.lib(qtmain_winrt.obj) : error LNK2019: unresolved external
symbol _WindowsDeleteString#4 referenced in function "public: void
__thiscall Microsoft::WRL::Wrappers::HString::Release(void)" (?Release#HString#Wrappers#WRL#Microsoft##QAEXXZ)
1>qtmaind.lib(qtmain_winrt.obj) : error LNK2019: unresolved external
symbol _WindowsGetStringRawBuffer#8 referenced in function "public:
wchar_t const * __thiscall
Microsoft::WRL::Wrappers::HString::GetRawBuffer(unsigned int *)const "
(?GetRawBuffer#HString#Wrappers#WRL#Microsoft##QBEPB_WPAI#Z)
1>qtmaind.lib(qtmain_winrt.obj) : error LNK2019: unresolved external
symbol _RoOriginateError#8 referenced in function "public: static void
__cdecl Microsoft::WRL::ErrorHelper<0>::OriginateError(long,struct HSTRING *)"
(?OriginateError#?$ErrorHelper#$0A##WRL#Microsoft##SAXJPAUHSTRING__###Z)
Qt 5.6-rc (22-Feb-2016 15:11)
link to WindowsApp.lib. That should resolve your issues.
At least for getting GetActivationFactory, you need to link to runtimeobject.lib.

Linker errors in Qt Creator 2.4.1 associated with CImg library

I wrote a small image processing algorithm using the CImg library and bundled it in a command line application using Visual C++ Express. Everything compiled error free and ran well, until the engineer in charge of the project decided he wanted a GUI. So I went to Qt and Qt creator. The GUI functioned fine by itself, but all hell breaks loose when I move my image processing algorithm over.
mainwindow.obj : error LNK2019: unresolved external
symbol__imp__SHGetSpecialFolderPathA#16 referenced in function "char const * __cdecl
cimg_library::cimg::programfiles_path(char const * const,bool)"
(?programfiles_path#cimg#cimg_library##YAPBDQBD_N#Z)
mainwindow.obj : error LNK2019: unresolved external symbol
__imp__EnumDisplaySettingsW#12 referenced in function "public: static int __cdecl
cimg_library::CImgDisplay::screen_width(void)"
(?screen_width#CImgDisplay#cimg_library##SAHXZ)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow#4
referenced in function "public: struct cimg_library::CImgDisplay & __thiscall
cimg_library::CImgDisplay::assign(void)"
(?assign#CImgDisplay#cimg_library##QAEAAU12#XZ)
mainwindow.obj : error LNK2019: unresolved external symbol
__imp__ChangeDisplaySettingsW#8 referenced in function "public: void __thiscall
cimg_library::CImgDisplay::_desinit_fullscreen(void)"
(?_desinit_fullscreen#CImgDisplay#cimg_library##QAEXXZ)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__SetWindowPos#28
referenced in function "public: struct cimg_library::CImgDisplay & __thiscall
cimg_library::CImgDisplay::resize(int,int,bool)"
(?resize#CImgDisplay#cimg_library##QAEAAU12#HH_N#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__AdjustWindowRect#12
referenced in function "public: struct cimg_library::CImgDisplay & __thiscall
cimg_library::CImgDisplay::resize(int,int,bool)"
(?resize#CImgDisplay#cimg_library##QAEAAU12#HH_N#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageW#4
referenced in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__GetMessageW#16
referenced in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__SetWindowLongW#12
referenced in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__GetDC#4 referenced
in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol
__imp__SetForegroundWindow#4 referenced in function "public: static unsigned long
__stdcall cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__GetWindowRect#8
referenced in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA#48
referenced in function "public: static unsigned long __stdcall
cimg_library::CImgDisplay::_events_thread(void *)"
(?_events_thread#CImgDisplay#cimg_library##SGKPAX#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcW#16
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__ShowCursor#4
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__TrackMouseEvent#4
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__PeekMessageW#20
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__ShowWindow#8
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__GetWindowLongW#8
referenced in function "public: static long __stdcall
cimg_library::CImgDisplay::_handle_events(struct HWND__ *,unsigned int,unsigned
int,long)" (?_handle_events#CImgDisplay#cimg_library##SGJPAUHWND__##IIJ#Z)
mainwindow.obj : error LNK2019: unresolved external symbol __imp__SetDIBitsToDevice#48
referenced in function "public: struct cimg_library::CImgDisplay & __thiscall
cimg_library::CImgDisplay::paint(void)" (?paint#CImgDisplay#cimg_library##QAEAAU12#XZ)
debug\final.exe : fatal error LNK1120: 20 unresolved externals
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
\BIN\nmake.exe"' : return code '0x2'
Stop.
My problem now, is I have no idea why I'm having linker trouble. The CImg library is a single H file. It's part of the project and included. I know Qt Creator needs libraries added to the project file, but what is there to add? My library is already listed under headers.
Here is the project file.
QT += core gui
TARGET = final
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
C:/includes/CImg.h
FORMS += mainwindow.ui
INCLUDEPATH += C:\includes\
Thanks for the assistance, I'm primarily an embedded systems programmer, and working out of my C and assembly element is getting very frustrating.
You need to link the Cimg library to you GUI program. Add the library in your .pro file.
LIBS += -L$PATH_TO_CIMG_LIB -l$CIMG_LIB
try compiling the cimg header file to a static library
and use (libs+=...youtstaticlibrary) i use visual studio so i cant help you how to add library's to qt , figure that out your self.
steps to compile to static library
eg. create CIMG_LIB project(console project) (or any name you like)
and in your source file include cimg header.
use namespace cimg_library in source code ( dont add anything else here )
compile the project to static library
--> create GUI project with qt
include header file in your project
add library that you previously created..
and ur good to go.

Creating class from existing Qt class

I've gone through the Qt 4.7 C++ tutorials and I've started a project to extend some of the functionality of QTreeView.
I'm attempting to do the following:
ensuring the program runs fine using QTreeView
copying and pasting new files based on ..\src\gui\itemviews\qtreeview.cpp, qtreeview.h, and qtreeview_p.h
replacing "QTreeView" to "CustomTreeView" in each filename and within each file (including the .pro file)
I am getting the following warnings (using MSVC, command-line):
.\CustomTreeView.cpp(147) : warning C4273: 'CustomTreeView::CustomTreeView' : inconsistent dll linkage
c:\home\jetimms\code\projects\CustomTreeViewTest\CustomTreeView.hpp(31) : see previous definition of '{ctor}'
There are many more of these warnings, but they look the same as above.
Also, I have these errors:
.\CustomTreeView.cpp(1216) : error C2248: 'NoState' : cannot access protected enumerator declared in class 'QAbstractItemView'
c:\qt\4.7.0\include\qtgui\../../src/gui/itemviews/qabstractitemview.h(304) : see declaration of 'NoState'
c:\qt\4.7.0\include\qtgui\../../src/gui/itemviews/qabstractitemview.h(63) : see declaration of 'QAbstractItemView'
.\CustomTreeView.cpp(1216) : error C2248: 'EditingState' : cannot access protected enumerator declared in class 'QAbstractItemView'
c:\qt\4.7.0\include\qtgui\../../src/gui/itemviews/qabstractitemview.h(307) : see declaration of 'EditingState'
c:\qt\4.7.0\include\qtgui\../../src/gui/itemviews/qabstractitemview.h(63) : see declaration of 'QAbstractItemView'
The above is complaining about the equivalent of the following (in qtreeview.h) with no changes except replacing QTreeView with CustomTreeView:
bool QTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos)
{
Q_Q(QTreeView);
// we want to handle mousePress in EditingState (persistent editors)
if ((state != QAbstractItemView::NoState
&& state != QAbstractItemView::EditingState)
|| !viewport->rect().contains(pos))
return true;
int i = itemDecorationAt(pos);
if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {
if (viewItems.at(i).expanded)
collapse(i, true);
else
expand(i, true);
if (!isAnimating()) {
q->updateGeometries();
viewport->update();
}
return true;
}
return false;
}
I have included these new files in the .pro file in the SOURCES and HEADERS. I do not have extra versions of the constructor included as the above warning says.
updated: 20110710_0926
Here is the actual code that causes the errors:
bool CustomTreeViewPrivate::expandOrCollapseItemAtPos(const QPoint &pos) {
Q_Q(CustomTreeView);
// we want to handle mousePress in EditingState (persistent editors)
if ((state != QAbstractItemView::NoState
&& state != QAbstractItemView::EditingState)
|| !viewport->rect().contains(pos))
return true;
int i = itemDecorationAt(pos);
if ((i != -1) && itemsExpandable && hasVisibleChildren(viewItems.at(i).index)) {
if (viewItems.at(i).expanded)
collapse(i, true);
else
expand(i, true);
if (!isAnimating()) {
q->updateGeometries();
viewport->update();
}
return true;
}
return false;
}
updated 20110710_1339:
When I attempted to compile (using qmake, as before) replacing my custom class with the qtreeview files in ..\src\gui\itemviews\, I received very similar warnings.
c:\Qt\4.7.0\src\gui\itemviews\qtreeview.cpp(187) : warning C4273: 'QTreeView::QTreeView' : inconsistent dll linkage
c:\qt\4.7.0\src\gui\itemviews\qtreeview.h(74) : see previous definition
of '{ctor}'
There is only one error that appears with this try and it has to do with (moc_qtreeview.cpp which is compiled on the fly?):
C:\home\jetimms\code\projects\cashflow\debug\moc_qtreeview.cpp(95) : error C2491: 'QTreeView::staticMetaObject' : definition of dllimport static data member not allowed
Not sure if it tells me anything related to the cause of the warnings. Here is that snippit of code:
const QMetaObject QTreeView::staticMetaObject = {
{ &QAbstractItemView::staticMetaObject, qt_meta_stringdata_QTreeView,
qt_meta_data_QTreeView, 0 }
};
I just find it strange that the QTreeView files themselves error out when I try to build with them.
Anyhow, the warning is telling me that the constructor for QTreeView has already been defined. I have guards on all of my header files, so there's nowhere that I can think of that it would think the QTreeView was defined twice.
updated: 20110710_1612
Here is the beginning of QTreeView.h with the definition of QTreeView. Note that it includes the QAbstractItemView.h and inherits from it.
#include <QtGui/qabstractitemview.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_TREEVIEW
class QTreeViewPrivate;
class QHeaderView;
class Q_GUI_EXPORT QTreeView : public QAbstractItemView
{
...
In exactly the same way, my custom class inherits from it.
#include <QtGui/qabstractitemview.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#ifndef QT_NO_TREEVIEW
class CustomTreeViewPrivate;
class QHeaderView;
class Q_GUI_EXPORT CustomTreeView : public QAbstractItemView
{
updated: 20110710_1757
It dawned on me that the code I was copying from QTreeView is for a library and I am not building a library, just the .exe for my app. I removed the Q_GUI_EXPORT from the constructor (just above) and the warnings I was experiencing were gone.
Now I am getting an error dealing with the moc_CustomTreeView.cpp file (there are 3 errors in all, all like this one):
debug\moc_CustomTreeView.cpp(140) : error C2027: use of undefined type 'CustomTreeViewPrivate'
c:\home\jetimms\code\projects\cashflow\debug\../CustomTreeView.hpp(12) : see declaration of 'CustomTreeViewPrivate'
debug\moc_CustomTreeView.cpp(140) : error C2227: left of '->_q_endAnimatedOperation' must point to class/struct/union/generic type
Here's the offending code:
case 16: d_func()->_q_endAnimatedOperation(); break;
Not sure what to do about the moc_ file errors. d_func() grabs the CustomTreeViewPrivate instance, but the moc_ file scope can't see it.
updated: 20110710_1757
I looked around to understand moc_ files and the Qt way of development and found these two.
KDE Techbase Policies/Library Code Policy This one explains why the Qt code is written as it is, using private classes and such.
I also found the following page that explains what to do when your moc_ code gives you errors like the ones I have above (rerun qmake), Using the Meta-Object Compiler (moc). I tried this and the above moc_ errors went away and now I am presented with these.
Bye the way, I changed the CustomTreeView name to SummaryDrillDownTreeView2.
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall QAbstractItemViewPrivate::~QAbstractItemViewPrivate(void)" (??1QAbstractItemViewPrivate##UAE#XZ) referenced in function __unwindfunclet$??0SummaryDrillDownTreeView2Private##QAE#XZ$0
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: __thiscall QAbstractItemViewPrivate::QAbstractItemViewPrivate(void)" (??0QAbstractItemViewPrivate##QAE#XZ) referenced in function "public: __thiscall SummaryDrillDownTreeView2Private::SummaryDrillDownTreeView2Private(void)" (??0SummaryDrillDownTreeView2Private##QAE#XZ)
SummaryDrillDownTreeView2.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_rowsRemoved(class QModelIndex const &,int,int)" (?_q_rowsRemoved#QAbstractItemViewPrivate##UAEXABVQModelIndex##HH#Z)
SummaryDrillDownTreeView2.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_columnsInserted(class QModelIndex const &,int,int)" (?_q_columnsInserted#QAbstractItemViewPrivate##UAEXABVQModelIndex##HH#Z)
SummaryDrillDownTreeView2.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_layoutChanged(void)" (?_q_layoutChanged#QAbstractItemViewPrivate##UAEXXZ)
SummaryDrillDownTreeView2.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::selectAll(class QFlags<enum QItemSelectionModel::SelectionFlag>)" (?selectAll#QAbstractItemViewPrivate##UAEXV?$QFlags#W4SelectionFlag#QItemSelectionModel#####Z)
SummaryDrillDownTreeView2.obj : error LNK2001: unresolved external symbol "public: virtual enum QAbstractItemView::DropIndicatorPosition __thiscall QAbstractItemViewPrivate::position(class QPoint const &,class QRect const &,class QModelIndex const &)const " (?position#QAbstractItemViewPrivate##UBE?AW4DropIndicatorPosition#QAbstractItemView##ABVQPoint##ABVQRect##ABVQModelIndex###Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: void __thiscall QAbstractItemViewPrivate::doDelayedItemsLayout(int)" (?doDelayedItemsLayout#QAbstractItemViewPrivate##QAEXH#Z) referenced in function "public: void __thiscall SummaryDrillDownTreeView2::setRowHidden(int,class QModelIndex const &,bool)" (?setRowHidden#SummaryDrillDownTreeView2##QAEXHABVQModelIndex##_N#Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: void __thiscall QAbstractItemViewPrivate::interruptDelayedItemsLayout(void)const " (?interruptDelayedItemsLayout#QAbstractItemViewPrivate##QBEXXZ) referenced in function "public: void __thiscall SummaryDrillDownTreeView2::expandAll(void)" (?expandAll#SummaryDrillDownTreeView2##QAEXXZ)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_modelDestroyed(void)" (?_q_modelDestroyed#QAbstractItemViewPrivate##UAEXXZ) referenced in function "public: virtual void __thiscall SummaryDrillDownTreeView2Private::_q_modelDestroyed(void)" (?_q_modelDestroyed#SummaryDrillDownTreeView2Private##UAEXXZ)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: virtual class QList<struct QPair<class QRect,class QModelIndex> > __thiscall QAbstractItemViewPrivate::draggablePaintPairs(class QList<class QModelIndex> const &,class QRect *)const " (?draggablePaintPairs#QAbstractItemViewPrivate##UBE?AV?$QList#U?$QPair#VQRect##VQModelIndex######ABV?$QList#VQModelIndex####PAVQRect###Z) referenced in function "public: virtual class QList<struct QPair<class QRect,class QModelIndex> > __thiscall SummaryDrillDownTreeView2Private::draggablePaintPairs(class QList<class QModelIndex> const &,class QRect *)const " (?draggablePaintPairs#SummaryDrillDownTreeView2Private##UBE?AV?$QList#U?$QPair#VQRect##VQModelIndex######ABV?$QList#VQModelIndex####PAVQRect###Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: class QStyleOptionViewItemV4 __thiscall QAbstractItemViewPrivate::viewOptionsV4(void)const " (?viewOptionsV4#QAbstractItemViewPrivate##QBE?AVQStyleOptionViewItemV4##XZ) referenced in function "protected: void __thiscall SummaryDrillDownTreeView2::drawTree(class QPainter *,class QRegion const &)const " (?drawTree#SummaryDrillDownTreeView2##IBEXPAVQPainter##ABVQRegion###Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: struct QEditorInfo __thiscall QAbstractItemViewPrivate::editorForIndex(class QModelIndex const &)const " (?editorForIndex#QAbstractItemViewPrivate##QBE?AUQEditorInfo##ABVQModelIndex###Z) referenced in function "protected: virtual void __thiscall SummaryDrillDownTreeView2::drawRow(class QPainter *,class QStyleOptionViewItem const &,class QModelIndex const &)const " (?drawRow#SummaryDrillDownTreeView2##MBEXPAVQPainter##ABVQStyleOptionViewItem##ABVQModelIndex###Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: void __thiscall QFramePrivate::updateStyledFrameWidths(void)" (?updateStyledFrameWidths#QFramePrivate##QAEXXZ) referenced in function "public: void __thiscall SummaryDrillDownTreeView2Private::initialize(void)" (?initialize#SummaryDrillDownTreeView2Private##QAEXXZ)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_columnsAboutToBeRemoved(class QModelIndex const &,int,int)" (?_q_columnsAboutToBeRemoved#QAbstractItemViewPrivate##UAEXABVQModelIndex##HH#Z) referenced in function "public: virtual void __thiscall SummaryDrillDownTreeView2Private::_q_columnsAboutToBeRemoved(class QModelIndex const &,int,int)" (?_q_columnsAboutToBeRemoved#SummaryDrillDownTreeView2Private##UAEXABVQModelIndex##HH#Z)
SummaryDrillDownTreeView2.obj : error LNK2019: unresolved external symbol "public: virtual void __thiscall QAbstractItemViewPrivate::_q_columnsRemoved(class QModelIndex const &,int,int)" (?_q_columnsRemoved#QAbstractItemViewPrivate##UAEXABVQModelIndex##HH#Z) referenced in function "public: virtual void __thiscall SummaryDrillDownTreeView2Private::_q_columnsRemoved(class QModelIndex const &,int,int)" (?_q_columnsRemoved#SummaryDrillDownTreeView2Private##UAEXABVQModelIndex##HH#Z)
debug\cashflow.exe : fatal error LNK1120: 16 unresolved externals
You should use inheritance to create the new class, rather than copy and paste. Less code to maintain that way, and less likely to break with even minor Qt upgrades.
I can’t really say about MSVC, but those members are declared as protected for QAbstractTreeView, like the error says. You didn’t paste source related to errors, but I guess you are trying to use those protected members somehow that does not qualify as sub-class usage, maybe by doing an instance and using that?
EDIT:
if ((state != QAbstractItemView::NoState
This is the actual line that is causing the error. Here you are using a protected member of QAbstractView, which is not allowed, as protected members are purely allowed to use for subclasses.
If you class inherited the QAbstractView, you could use that member.

Resources