Link error while using QAudioDeviceInfo in QT console application - qt

I have created simple QT console application in Visual Studio 2019
Following is the code
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
std::cout << "Available Audio devices ";
QList<QAudioDeviceInfo> audioDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
return a.exec();
}
When compiledi am getting the following link error
>------ Build started: Project: AVSyncTesting, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QAudioDeviceInfo::~QAudioDeviceInfo(void)" (__imp_??1QAudioDeviceInfo##QEAA#XZ) referenced in function "public: void * __cdecl QAudioDeviceInfo::`scalar deleting destructor'(unsigned int)" (??_GQAudioDeviceInfo##QEAAPEAXI#Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QList<class QAudioDeviceInfo> __cdecl QAudioDeviceInfo::availableDevices(enum QAudio::Mode)" (__imp_?availableDevices#QAudioDeviceInfo##SA?AV?$QList#VQAudioDeviceInfo####W4Mode#QAudio###Z) referenced in function main

Try to use this code to get devices:
const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
for (const QAudioDeviceInfo &deviceInfo : deviceInfos)
qDebug() << "Device name: " << deviceInfo.deviceName();

Related

Cannot Integrate Opencv With Qt

I would like to integrate opencv249 with Qt 5.5. My .pro file is like that:
INCLUDEPATH += C:/OpenCV249/opencv/build/include
INCLUDEPATH += C:/OpenCV249/opencv/build/include/opencv
INCLUDEPATH += C:/OpenCV249/opencv/build/include/opencv2
LIBS += -LC:/OpenCV249/opencv/build/x86/vc12/lib
LIBS += -lopencv_core249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_features2d249 -lopencv_calib3d249
My code is like that:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
using namespace cv;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Mat im=imread("1.jpg");
imshow("kubi",im);
return a.exec();
}
It gives those errors:
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPEAX#Z) referenced in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat#cv##QEAA#XZ)
main.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QEAA#AEBVMat#1##Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QEAAXXZ) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release#Mat#cv##QEAAXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPEAHH#Z) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release#Mat#cv##QEAAXXZ)
main.obj:-1: error: LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEBV_InputArray#1##Z) referenced in function main
main.obj:-1: error: LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread#cv##YA?AVMat#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
debug\Sercan.exe:-1: error: LNK1120: 6 unresolved externals
I don't know how to fix it.
Is your lib path correct?
Should you change
LIBS += -LC:/opencv/build/x86/vc12/lib
with
LIBS += -LC:/OpenCV249/opencv/build/x86/vc12/lib
?
It's only a wild guess, everything else looks OK...

Q_OBJECT is giving me this linking error

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.

qt simple tcp communication with ui projects

I want to create a simple Tcp Communication project but I get some problems and I dont know how to solve that problem. When I try to find solution all people tell add this code (QT += network)on .pro file but in ui projects I dont have any pro file so I dont know the find the solution.
//commu.h
#ifndef COMMU_H
#define COMMU_H
#include <QtWidgets/QMainWindow>
#include "ui_commu.h"
#include <QtNetwork/QTcpSocket>
#include <QObject>
#include <QString>
class commu : public QMainWindow
{
Q_OBJECT
public:
commu(QWidget *parent = 0);
~commu();
void start(QString address, quint16 port);
private:
Ui::commuClass ui;
QTcpSocket client;
public slots:
void startTransfer();
};
#endif // COMMU_H
//commu.cpp
#include "commu.h"
#include <QtNetwork/QHostAddress>
commu::commu(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
connect(&client, SIGNAL(connected()),this,SLOT(startTransfer()));
}
commu::~commu()
{
client.close();
}
void commu::start(QString address, quint16 port)
{
QHostAddress addr(address);
client.connectToHost(addr, port);
}
void commu::startTransfer()
{
client.write("Hello, world", 13);
}
//main.cpp
#include "commu.h"
#include <QtWidgets/QApplication>
#include <QtCore>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
commu w;
w.show();
return a.exec();
commu client;
client.start("127.0.0.1", 8888);
}
I get the errors:
1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QTcpSocket::~QTcpSocket(void)" (__imp_??1QTcpSocket##UAE#XZ) referenced in function "public: virtual __thiscall commu::~commu(void)" (??1commu##UAE#XZ)
1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QTcpSocket::QTcpSocket(class QObject *)" (__imp_??0QTcpSocket##QAE#PAVQObject###Z) referenced in function "public: __thiscall commu::commu(class QWidget *)" (??0commu##QAE#PAVQWidget###Z)
1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::~QHostAddress(void)" (__imp_??1QHostAddress##QAE#XZ) referenced in function "public: void __thiscall commu::start(class QString,unsigned short)" (?start#commu##QAEXVQString##G#Z)
1>commu.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::QHostAddress(class QString const &)" (__imp_??0QHostAddress##QAE#ABVQString###Z) referenced in function "public: void __thiscall commu::start(class QString,unsigned short)" (?start#commu##QAEXVQString##G#Z)
1>c:\users\sel\documents\visual studio 2010\Projects\commu\Win32\Debug\\commu.exe : fatal error LNK1120: 4 unresolved externals
You need to enable modules you're using in Qt Project Settings. More info you can find in Qt docs: Qt Visual Studio Add-in
You also shouldn't use includes like
#include <QtWidgets/QMainWindow>
you should always include only class file without path like
#include <QMainWindow>
Same goes for all modules, so skip QtNetwork etc after you enable modules for your project.

QSqlDatabase LNK2019 error

I tried to compile the following code in Qt 5.0.0:
#include <QApplication>
#include <QtSql/QSql>
#include <Qtsql/QSqlDatabase>
#include <QStringList>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QStringList db = QSqlDatabase::drivers();
return a.exec();
}
and I received this error:
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QStringList __cdecl QSqlDatabase::drivers(void)" (__imp_?drivers#QSqlDatabase##SA?AVQStringList##XZ) referenced in function _main
debug\test.exe:-1: error: LNK1120: 1 unresolved externals
I have added QT += sql in my .pro. What's the problem?
You should add QtSql.lib ( you can find the name of Qtsql exactly in QT/lib in your computer) by go to Project/Properties/Configuration properties/Linker/Input, add QtSql.lib to Additional Dependencies
P.S. I used to face this error, and the error is fixed by this way. Good luck

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