[Qt-interest] QTableWidget and QList<QStringList> Segment Fault , Please Help
Aaron Lewis
aaron.lewis1989 at gmail.com
Sun Mar 28 10:11:42 CEST 2010
Hi,
Please see my code below , don't know why.
Thanks in advance ;-)
Result:
ASSERT failure in QList<T>::at: "index out of range", file
/tools/Opt/qt4-opensrc/include/QtCore/qlist.h, line 439
The program has unexpectedly finished.
QTableWidget tableWidget has 9 columns , it's set with Qt Designer.
---------------------------------------------------------------
//Caller:
QList<QStringList> list;
QStringList t1;
t1 << "a" << "b" << "c" << "d" << "f" << "g" << "h" << "i" << "j";
list << t1 << t1 << t1;
setHeader(list);
---------------------------------------------------------------
//Func
void xxx::setHeader(const QList<QStringList> &list)
{
QStringList tmp;
ui->tableWidget->setRowCount(list.count());
qDebug() << "Row Count: " << ui->tableWidget->rowCount();
qDebug() << "Colunm Count: " << ui->tableWidget->columnCount();
for(int i=0;i<ui->tableWidget->columnCount();i++){
tmp = list.at(i);
qDebug() << "=========";
for(int j=0;j<tmp.count();j++){
qDebug() << QString("Map <%1,%2> is
%3").arg(i).arg(j).arg(tmp.at(j));
ui->tableWidget->setItem(i,j,new QTableWidgetItem(tmp.at(j)));
}
}
}
--
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
More information about the Qt-interest-old
mailing list