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. Does it have to call QTableWidget::setItem for every cell?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.1k Views 2 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.
  • jronaldJ Offline
    jronaldJ Offline
    jronald
    wrote on last edited by jronald
    #1

    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?
    mrjjM 1 Reply Last reply
    0
    • jronaldJ jronald

      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?
      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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

      1 Reply Last reply
      3
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        2

        • Login

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