[Qt-interest] problem filling a QtableWidget

Tibor Kiss tibor at wiesen.at
Fri May 28 20:05:38 CEST 2010


Hi!

At my opinion you should make new QTableWidgetItems in each loop. Like this:

while(..) {

    QTableWidgetItem *item = new QTableWidgetItem();
    item->setText(query4.value(0).toString());
    ui->tabla->setItem(a, 0, item);

....
}

My other guess that maybe you need to add rows, with
QTableWidget::insertRow(rowcount) at each loop.

Tibor

2010/5/26 mierdatutis mi <mmm286 at gmail.com>

> Hi,
>
> I have a problem filling a qtablewidget. Allways fill the first row. I 've
> checked the code but I dont see any error. Could you help me please? Many
> thanks and sorry for my english!
>
> The code is:
>
> ui->tabla->setColumnCount(5);
>          while ( query4.next() )
>
>        {
>            //QString group = query4.value( 0 ).toString();
>
>            item->setText(query4.value(0).toString());
>            ui->tabla->setItem(a,0,item);
>            item2->setText(query4.value(1).toString());
>
>            ui->tabla->setItem(a,1,item2);
>            item3->setText(query4.value(2).toString());
>            ui->tabla->setItem(a,2,item3);
>            item4->setText(query4.value(3).toString());
>
>            ui->tabla->setItem(a,3,item4);
>            //QMessageBox::information(this,"",query4.value(3).toString());
>            item5->setText(query4.value(4).toString());
>            ui->tabla->setItem(a,4,item5);
>
>            a++;
>        }
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100528/003c0ae7/attachment.html 


More information about the Qt-interest-old mailing list