QTableWidgetItem text() function not linking ?
Hello,
I want to get the text of a cell of a tablewidget on my form.
I have already filled the tablewidget with new tablewidgetitems using setItem(), and all text is showing fine in my first test program.
Now i try to write a 'getter' function using the QTablewidget text() function like this :
Code:
QString CMainDialog
::getTableText( int nRow,
int nCol
) {
if( pCell!=NULL )
sResult = pCell->text();
return sResult;
}
Compiling goes fine, but then I get a linker error saying
mainDialog.obj:: error: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QTableWidgetItem::text(void)const " (__imp_?text@QTableWidgetItem@@QBE?AVQString@@XZ)
I am working with QtCreator and have Qt 4.6.3 statically linked with the MS VC compiler.
Has anyone already encountered this ? Or better yet, has a solution for this ?
Best regards,
Marc
Re: QTableWidgetItem text() function not linking ?
Do you link the right lib files to your code? Do you have build Qt static for release and debug mode?
Re: QTableWidgetItem text() function not linking ?
Hi Lykurg,
Linking fails both in debug and release mode. I have built Qt statically both for release and debug mode.
QtCreator makes my .pro file, and Qt core and gui are included. I just added stuff to use QextSerialPort (which is working by the way, so that's not the issue). I would be surprised if I had to manually add an extra LIB just to use a QTableWidget.
Code:
QT += core gui
TARGET = DibScan
TEMPLATE = app
SOURCES += main.cpp\
mainDialog.cpp
HEADERS += mainDialog.h
FORMS += mainDialog.ui
INCLUDEPATH += ".\include"
LIBS += -lqextserialport
win32:DEFINES = _TTY_WIN_ QWT_DLL QT_DLL
I don't see why the QTableWidgetItem::setText() function is no problem, but the text() function is. It should be in the same source file in Qt I would think.
Best regards,
Marc
Re: QTableWidgetItem text() function not linking ?
Can't see "CONFIG += static" and I don't know QT_DLL exactly, but dll is not what you want when you link static. I am a little confused. ([WIKI]Building static Qt on Windows[/WIKI])
Re: QTableWidgetItem text() function not linking ?
Hi Lykurg,
Thanks, you pointed me in the right direction.
I just blindly copied the #win32:DEFINES = _TTY_WIN_ QWT_DLL QT_DLL from the example with QextSerialport to my .pro file. I tought it just had to do something with Qextserialport.
But the QT_DLL and QWT_DLL defines are of course not allowed for a static application. Everything works if I leave it out.
I'm not sure why I don't need the CONFIG += static line. I think it is because I modified the QMAKE_CFLAGS / CXXFLAGS / LFLAGS directly in the qmake.conf file in the mkspecs directory.
Best regards,
Marc