Unresolved symbol: QTreeWidgetItem::itemFromIndex(QModelIndexconst&) const
Michael Drüing
michael at drueing.de
Wed Apr 12 01:17:52 CEST 2006
> -----Original Message-----
> From: David Faure [mailto:faure at kde.org]
> Sent: Wednesday, April 12, 2006 12:24 AM
> To: kde-buildsystem at kde.org
> Subject: Re: Unresolved symbol:
> QTreeWidgetItem::itemFromIndex(QModelIndexconst&) const
>
> On Wednesday 12 April 2006 00:17, Maarten Th. Mulders wrote:
> > Hi all,
> >
> > when linking kdeui with MSVC 2005 the following linker error occurs:
> >
> > ktreewidgetsearchline.obj : error LNK2019: unresolved
> external symbol
> > "__declspec(dllimport) public: class QTreeWidgetItem * __thiscall
> > QTreeWidget::itemFromIndex(class QModelIndex const &)const "
> >
> (__imp_?itemFromIndex at QTreeWidget@@QBEPAVQTreeWidgetItem@@ABVQ
ModelIndex@@@Z)
> > referenced in
> > function "private: void __thiscall
> > KTreeWidgetSearchLine::rowsInserted(class QModelIndex
> > const&,int,int)const "
> > (?rowsInserted at KTreeWidgetSearchLine@@ABEXABVQModelIndex@@HH at Z)
> >
> > I can't find any Qt patches related to QTreeWidgetItem or
> whatsoever.
>
> QTreeWidget::itemFromIndex is a protected method in a public
> class, there's no reason
> for this link error, except if your kdeui is linking to an
> older version of Qt for some reason.
> Check that you don't have older Qt libs (e.g. with or without
> the "d" for debug)
> in your $QTDIR/lib.
I think MSVC somehow encodes member visibility in the mangled symbol names,
so the symbol of a public function differs from that of a protected
function, even if their prototypes match.
That would explain why the hack in ktreewidgetsearchline.cpp [*] doesn't
work. To test it, I tried changing itemFromIndex() from protected to public
in Qt's qtreewidget.h, and after recompiling Qt I could successfully link
kdeui.dll.
Note that I'm using Qt 4.1.2, so it might be that the problem only occured
recently and it probably wasn't there in earlier versions.
--Michael
[*]:
// Only feeling a touch guilty about this
// Need QTreeWidget::itemFromIndex
#define protected public
#include <QTreeWidget>
More information about the Kde-buildsystem
mailing list