[Qt-interest] QTableWidget: cannot insert an item that is already owned by another QTableWidget
Bijay Panda
bijay at analytica-india.com
Thu May 28 08:16:42 CEST 2009
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 .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090528/03e18a75/attachment.html
More information about the Qt-interest-old
mailing list