Results 1 to 5 of 5

Thread: QTableWidgetItem text() function not linking ?

  1. #1
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question 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 :

    Qt Code:
    1. QString CMainDialog::getTableText( int nRow, int nCol )
    2. {
    3. QString sResult="-";
    4. QTableWidgetItem *pCell = ui->tblPorts->item( nRow, nCol );
    5.  
    6. if( pCell!=NULL )
    7. sResult = pCell->text();
    8.  
    9. return sResult;
    10. }
    To copy to clipboard, switch view to plain text mode 


    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

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default 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?

  3. #3
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

    Qt Code:
    1. QT += core gui
    2. TARGET = DibScan
    3. TEMPLATE = app
    4. SOURCES += main.cpp\
    5. mainDialog.cpp
    6. HEADERS += mainDialog.h
    7. FORMS += mainDialog.ui
    8. INCLUDEPATH += ".\include"
    9. LIBS += -lqextserialport
    10. win32:DEFINES = _TTY_WIN_ QWT_DLL QT_DLL
    To copy to clipboard, switch view to plain text mode 

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default 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])
    Last edited by Lykurg; 10th September 2010 at 15:27. Reason: spelling corrections

  5. The following user says thank you to Lykurg for this useful post:

    marcvanriet (10th September 2010)

  6. #5
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidgetItem text() function not linking ?

    Hi Lykurg,

    Thanks, you pointed me in the right direction.

    I just blindly copied the #win32EFINES = _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

Similar Threads

  1. Extracting text from QTableWidgetItem
    By bizmopeen in forum Newbie
    Replies: 3
    Last Post: 1st September 2009, 17:28
  2. QTableWidgetItem Text Editing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 02:23
  3. Rich Text in QTableWidgetItem
    By joshuajcarson in forum Qt Programming
    Replies: 9
    Last Post: 2nd September 2008, 15:49
  4. QTableWidgetItem Text
    By pytro in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2007, 21:44
  5. Auto text select in QTableWidgetItem
    By tstankey in forum Newbie
    Replies: 2
    Last Post: 5th October 2006, 20:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.