PDA

View Full Version : Problem creating a QTableWidgetIem



DiegoTc
28th September 2010, 03:44
Hi everyone. I have been searching on google and couldn't found an answer(Probably I didn't search well)
I am having troubles creating a QTableWidgetItem


QString mes=get_Character(opt);
QTableWidgetItem *item=new QTableWidgetItem(mes,1000);
ui->tableWidget->setItem(i,j,item);


I supoose the constructor is well done.
According to this QTableWidgetItem::QTableWidgetItem ( const QString & text, int type = Type
If nop I miss understood that part.
Thank you :)

tbscope
28th September 2010, 04:47
A type should be handled in a custom subclass I guess?
What happens if you don't use a custom type?

DiegoTc
28th September 2010, 05:43
tbscope
I don't understand you really.(English is not my native language)
But the program compiles, but at the moment of running it the program close automatically

tbscope
28th September 2010, 05:58
Try this:


ui->tableWidget->setRowCount(10);
ui->tableWidget->setColumnCount(5);

QTableWidgetItem *newItem = new QTableWidgetItem("Hello world!");
ui->tableWidget->setItem(2, 2, newItem);


First, set the amount of rows and columns.
Then construct a new table widget item and add set it in a certain cell.

DiegoTc
28th September 2010, 18:05
I have a QTableWidget created with 8 rows and 15 columns. I created it graphically.
And this doesn't seems to work


QTableWidgetItem *newItem = new QTableWidgetItem("Hello world!");
ui->tableWidget->setItem(2, 2, newItem);