QTableWidget



  • Sometimes, when I try to decrease my TableWidget size, my program stops with an error in the second line line:
    @
    table->setColumnCount(size);
    table->setRowCount(size);
    @

    When the last size is bigger then then new one, program do it correctly, without any mistakes.

    all my function:
    @
    void MainWindow::setSize(int size) {
    int lastSize = table->rowCount();

    table->setColumnCount(size);
    table->setRowCount(size);
    
    if (size > lastSize) {
        table->setColumnWidth(size-1, table->rowHeight(1));
        QTableWidgetItem *item = new QTableWidgetItem(tr("x%1").arg(size));
        table->setHorizontalHeaderItem(size-1, item);
        table->setVerticalHeaderItem(size-1, item);
    }
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.