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. [Solved] How to insert data to qtablewidget?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to insert data to qtablewidget?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.7k 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.
  • R Offline
    R Offline
    rafae11
    wrote on last edited by
    #1

    the program creates rows and columns but no data is inserted
    what am i missing?

    @
    void MainWindow::errorString(QString err)
    {
    ui->tableWidget->setRowCount(current_row+1);
    ui->tableWidget->setColumnCount(5);
    current_row++;

    switch(err[3].toLatin1())
    {
        case 'B':
        {
            address_selection(err);
            ui->tableWidget->setItem(current_row,0, new QTableWidgetItem(err));
            //ui->tableWidget->setItem(current_row,0,new QTableWidgetItem("x"));
        }
        break;
    

    }
    }@

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bodzio131
      wrote on last edited by
      #2

      Let say current_row = 9. You set rowCount = 10, so table indexes are 0..9. Then you increment current_row and set data for row 10 which is out of table index.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rafae11
        wrote on last edited by
        #3

        thanks got it.

        1 Reply Last reply
        0

        • Login

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