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. When to use QTableWidgetItem?
Qt 6.11 is out! See what's new in the release blog

When to use QTableWidgetItem?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 480 Views
  • 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.
  • GuerrianG Offline
    GuerrianG Offline
    Guerrian
    wrote on last edited by Guerrian
    #1

    Is it a case of use it when you need to, or should you always create an instance for every cell of a QTableWidget? A related question: is the QTableWidgetItem object purely a conduit to pass values to a cell of a QTableWidget object (so that the QTableWidgetItem object can be immediately deleted)?

    Linux Mint 18.3
    Qt 5.14.1
    Qt Creator 4.11.1

    aha_1980A 1 Reply Last reply
    0
    • GuerrianG Guerrian

      Is it a case of use it when you need to, or should you always create an instance for every cell of a QTableWidget? A related question: is the QTableWidgetItem object purely a conduit to pass values to a cell of a QTableWidget object (so that the QTableWidgetItem object can be immediately deleted)?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      Hi @Guerrian, welcome to the forums.

      Is it a case of use it when you need to, or should you always create an instance for every cell of a QTableWidget?

      Yes, the typical usage is to create a new QTableWidgetItem if you change the cell, see the example at http://doc.qt.io/qt-5/qtablewidgetitem.html#details

      A related question: is the QTableWidgetItem object purely a conduit to pass values to a cell
      of a QTableWidget object

      Yes, that is correct.

      (so that the QTableWidgetItem object can be immediately deleted)?

      No, you don't delete it! The QTableWidget takes ownership of your QTableWidgetItem: http://doc.qt.io/qt-5/qtablewidget.html#setItem so you are no longer responsible for that.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      3

      • Login

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