Does it have to call QTableWidget::setItem for every cell?



  • Not quite clear about the usage about QTableWidget. (not in view/model mode)
    After setColumnCount and setColumnCount, run the program, what confuse me is:

    1. The table widget works (click to edit, saved to UI after editing), but QTableWidget::item returns null for a existing cell, so the properties of the cell can't be modified
    2. Does it have to call QTableWidget::setItem for every cell?

  • Qt Champions 2016

    Hi
    setRowCount();
    setColumnCount();

    That only sets how many to expect. You must insert as many items as you specify.

    https://wiki.qt.io/How_to_Use_QTableWidget


  • Moderators

    Remember that we're not talking about abstract things. Items take memory. If you have an empty 10000x10000 table that just holds the width and the height - it costs almost nothing, but fill it up with items and you've got yourself a real memory hog.
    Only insert the items you actually need.


Log in to reply
 

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