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. how to remove Item in Qtablewidget?
QtWS25 Last Chance

how to remove Item in Qtablewidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidgetitemdelete
3 Posts 3 Posters 2.1k 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.
  • F Offline
    F Offline
    ForestPoem
    wrote on 15 Dec 2015, 01:44 last edited by ForestPoem
    #1

    Hi. Guys

    my source code ↓
    ui->tableWidget->setItem(0,7,new QTableWidgetItem(QString::number(3)));
    ui->tableWidget->item(0,7)->setTextAlignment(Qt::AlignCenter);

    my way this.

    delete ui->tableWidget->item(0,7);

    If this memory is free?

    If not let me know any other method.

    R 1 Reply Last reply 15 Dec 2015, 04:48
    0
    • F ForestPoem
      15 Dec 2015, 01:44

      Hi. Guys

      my source code ↓
      ui->tableWidget->setItem(0,7,new QTableWidgetItem(QString::number(3)));
      ui->tableWidget->item(0,7)->setTextAlignment(Qt::AlignCenter);

      my way this.

      delete ui->tableWidget->item(0,7);

      If this memory is free?

      If not let me know any other method.

      R Offline
      R Offline
      Ratzz
      wrote on 15 Dec 2015, 04:48 last edited by
      #2

      @ForestPoem
      May be deleting the pointer directly as mentioned here .

      --Alles ist gut.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 15 Dec 2015, 05:38 last edited by
        #3

        When you set the item, The table takes ownership of the item. So just deleting the tableWidget should satisfy. If you want to selectively delete, what you are doing should be good enough.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        3

        1/3

        15 Dec 2015, 01:44

        • Login

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