PDA

View Full Version : Unable to see the table created by QTableWidget



swathisri
25th June 2013, 12:50
Hi
I created a QTableWidget with 2columns and 0 rows and am receiving some information from a socket in a while loop. When i tried to add that informtion to table table is not at all displaying.
Can anyone help .

Here is my code

while(1)
{

len = zmq_msg_recv (&zmq_msg, zmq_sock_in, ZMQ_DONTWAIT);
if (len > 0) {
msg = (char*) zmq_msg_data (&zmq_msg);
QTableWidgetItem *item_val,*item_name;

item_name = new QTableWidgetItem;
item_val = new QTableWidgetItem;

row = table->rowCount();
qDebug("Current row is:%d",row);
table->insertRow(row);

item_name->setText(name);
item_val->setText(val);

table->repaint();
table->setItem(row,0,item_name);
table->setItem(row,1,item_val);

}

}

nix
25th June 2013, 13:15
Have you something like this in your code before this loop :
table.setColumnCount(2);
And
table.repaint(); is not required.