Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget update items.
Forum Updated to NodeBB v4.3 + New Features

QTableWidget update items.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Overflowz
    wrote on 31 Dec 2012, 14:53 last edited by
    #1

    Hi, I'm having trouble with updating QTableWidgetItems. I don't understand what I'm doing wrong :(
    [code]void MainWindow::fillTable(QList<QByteArray> Info)
    {
    int Row = ui->clientsList->rowCount() - 1; //Starts from 0.

    //Check if client row already exists.
    for(int i = Row; i >= 0; i--)
    {
        if(ui->clientsList->item(i, 0)->text().contains(QString(Info[1])))
        {
            //Update row.
            for(int u = 0; u < Info.count() - 1; u++)
            {
                ui->clientsList->setItem(i, u, new QTableWidgetItem(QString(Info[u + 1])));
            }
    
            return; //avoid new row insertion.
        }
    }
    
    //Insert new row.
    Row = ui->clientsList->rowCount() + 1;
    ui->clientsList->setRowCount(Row);
    for(int i = 0; i < Info.count() - 1; i++)
    {
        //Fill rows.
        ui->clientsList->setItem(Row - 1, i, new QTableWidgetItem(QString(Info[i + 1])));
    }
    

    }[/code]

    Step by step problem.

    1. at first insertion = OK, all first cells are filled.
    2. updating firstly inserted items = OK, all first cells are updated.
    3. at second insertion = OK, all second cells are filled.
    4. updating second inserted items = OK, all second cells are updated.
    5. updating first inserted items = FAIL, all first cells are updated, but NEXT cell's first table is empty. WHY?
    1 Reply Last reply
    0

    1/1

    31 Dec 2012, 14:53

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved