undefined error when drived from QAbstractItemViewPrivate
-
Hi experts,
I am trying to do a CustomTreeView derived from QAbstractItemView with CustomTreeViewPrivate derived from QAbstractItemViewPrivate.
Here is my project--- CustomTreeView.pro ---- QT += gui widgets core widgets-private gui-private core-private SOURCES += main.cpp\ mainwindow.cpp \ CustomTreeView.cpp HEADERS += mainwindow.h \ CustomTreeView.h \ CustomTreeView_p.h ------ ------------------------------------------------------------ ----- CustomTreeView_p.h ----- class CustomTreeViewPrivate: public QAbstractItemViewPrivate { ... } ------ ------------------------------------------------------------ ----- CustomTreeView.h ----- class CustomTreeView: public QAbstractItemView { Q_OBJECT public: CustomTreeView(QWidget* parent) : QAbstractItemView (*new CustomTreeViewPrivate, parent) { ... } ... ... }
When compiling the project, it reports a lot "undefined symbol error" like below
error: undefined symbol: QAbstractItemViewPrivate::QAbstractItemViewPrivate
error: undefined symbol: QAbstractItemViewPrivate::~QAbstractItemViewPrivate
.....Do you know how to fix these errors ?
-
Private symbols are not exported by the pre-compiled Qt libraries. You need to compile Qt yourself either:
- defining
QT_BUILD_INTERNAL
(i.e use the-developer-build
configure option) to export private symbols - build Qt as a static library (i.e use the
-static
configure option)
QT += *-private
only deals with the headers, it can't export more symbols - defining