Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    3
    3
    683
    Loading More Posts
    • 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.
    • jronald
      jronald last edited by 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?
      mrjj 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion @jronald last edited by mrjj

        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 Reply Quote 3
        • Chris Kawa
          Chris Kawa Moderators last edited by

          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 Reply Quote 2
          • First post
            Last post