[Qt-interest] QTableWidget: cannot insert an item that is already owned by another QTableWidget

Malyushytsky, Alex alex at wai.com
Tue Jun 2 04:50:06 CEST 2009


The problem is explained in the error message you get.
One of the solution is to

Move:
    item_trackNo     = new QTableWidgetItem();
before:

    item_trackNo->setText(trackId);////trackId);


Alex


From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Bijay Panda
Sent: Wednesday, May 27, 2009 11:17 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QTableWidget: cannot insert an item that is already owned by another QTableWidget

Hi All,
I am using QTableWidget for creating a table. while inserting QTableWdgetItem into table it's showing an error  like bellow.
 "QTableWidget: cannot insert an item that is already owned by another QTableWidget ".

Here is my source code.
#include "HookWindow.h"
hookWindow::hookWindow(QWidget* parent, Qt::WFlags fl): QWidget (parent,fl)
{

    label_msg = new QLabel("  Hook Window ",this);

     _tableHookWindow = new QTableWidget(10,5,this);

    item_trackNo     = new QTableWidgetItem();


}
////////////////////////////////////////////////////////////////////////
hookWindow::~hookWindow(void)
{

}
////////////////////////////////////////////////////////////////////////
void hookWindow::createHookWindow(int width,int height)
{
    //label_msg = new QLabel("  Hook Window ",this);
    label_msg->setGeometry(2,0,width,30);
    label_msg->show();
    QFont font("Helvetica", 15, QFont::Bold);
    label_msg->setFont(font);


    //_tableHookWindow = new QTableWidget(10,5,this);
    _tableHookWindow->setGeometry(1,label_msg->y()+label_msg->height(),width,height-label_msg->height());
    _tableHookWindow->setColumnWidth( 0,width/4.5);
    _tableHookWindow->setColumnWidth( 1,width/5 );
    _tableHookWindow->setColumnWidth( 2,width/5 );
    _tableHookWindow->setColumnWidth( 3,width/5 );
    _tableHookWindow->setColumnWidth( 4,width/5 );
    _tableHookWindow->show();

    _addLabel<<"Track No" <<"Speed"<<"Height"<<"Hdng"<<"Idty";
    _tableHookWindow->setHorizontalHeaderLabels(_addLabel );



}

void hookWindow::slot_getHookWindowData(int track_id)
{

    trackId = QString::number(track_id);
    cout<<"track_id from hookWindow::"<<trackId.toAscii().data() <<endl;


    item_trackNo->setText(trackId);////trackId);
    _tableHookWindow->setItem(0,0,item_trackNo);

}
Can anyone please suggest me what can be the solution.
Any help is appreciated.
--
Thanks & Regards

Bijay .


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090601/3bb7e96f/attachment.html 


More information about the Qt-interest-old mailing list