PDA

View Full Version : [SOLVED] Retrieving data from QTableWidget



timmu
7th October 2011, 11:36
Hi,

I'm creating a QTableWidged based on my text file like this:



char readword[50]="";
for(i=0; i<6; i++)
{
for(j=0; j<5; j++)
{

fscanf(input,"%s", &readword);
QTableWidgetItem *refItem = new QTableWidgetItem(QString("%1").arg(readword));
refTable->setItem(i, j, refItem);
}
}


Then I'd like to see if I get the correct entru back out of the table (testing with location 1,1):



QTableWidgetItem *item = refTable->item(1,1);
QString celltext; celltext=item->text(); char print[50]; strcpy(print, celltext.toLocal8Bit().constData());

fprintf(output,"%s\n", print);


However, I'm not getting the same text back as what was in the input file. I'm getting text from a location other than 1,1.
I'd be very thankful for any help. It seems that I don't know how to handle QTAbleWidget or QTableWidgetItem