Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How I remove all data from a row in PySide2 without deleting the row
Forum Updated to NodeBB v4.3 + New Features

How I remove all data from a row in PySide2 without deleting the row

Scheduled Pinned Locked Moved Solved Qt for Python
12 Posts 2 Posters 2.9k 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.
  • B Offline
    B Offline
    BlueBreezy
    wrote on last edited by
    #3

    Ok thanks I will try that, and how I set it to no value is by doing this ```

    window.tableWidget.setItem(0,0 ,QTableWidgetItem())

    as you can see QTablewWidgetItem is blank and there is no value in the parenthesis

    1 Reply Last reply
    0
    • jsulmJ jsulm

      @BlueBreezy You can iterate through all columns in that row using https://doc.qt.io/qt-5/qtablewidget.html#item and delete/clear content of each item.

      "I have also tried setting the row to no value with setItem() " - can you show how you did this?

      B Offline
      B Offline
      BlueBreezy
      wrote on last edited by
      #4

      @jsulm wait I dont get it plus isn't that c++ docs

      jsulmJ 1 Reply Last reply
      0
      • B BlueBreezy

        @jsulm wait I dont get it plus isn't that c++ docs

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @BlueBreezy said in How I remove all data from a row in PySide2 without deleting the row:

        isn't that c++ docs

        It is, but it is the same interface in Python but with Python syntax...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        B 1 Reply Last reply
        0
        • jsulmJ jsulm

          @BlueBreezy said in How I remove all data from a row in PySide2 without deleting the row:

          isn't that c++ docs

          It is, but it is the same interface in Python but with Python syntax...

          B Offline
          B Offline
          BlueBreezy
          wrote on last edited by
          #6

          @jsulm So can the same be found here https://doc.qt.io/qtforpython/PySide2/QtWidgets/QTableWidget.html

          also its just

          QTableWidget::item(int row, int column) const
          

          so how would I go about deleting a row with just that?

          jsulmJ 1 Reply Last reply
          0
          • B BlueBreezy

            @jsulm So can the same be found here https://doc.qt.io/qtforpython/PySide2/QtWidgets/QTableWidget.html

            also its just

            QTableWidget::item(int row, int column) const
            

            so how would I go about deleting a row with just that?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by jsulm
            #7

            @BlueBreezy said in How I remove all data from a row in PySide2 without deleting the row:

            deleting a row with just that?

            You don't want to delete a row, right? You want to remove the content in all cells in a row if I understood you correctly. Using item(...) you get the item in the given cell and can then reset its content. For example if you have text in an item you can use https://doc.qt.io/qt-5/qtablewidgetitem.html#setText to set empty string in it.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            B 1 Reply Last reply
            0
            • B Offline
              B Offline
              BlueBreezy
              wrote on last edited by
              #8

              oh okay I get you sorry I got confused im not deleting the row but let me see

              1 Reply Last reply
              0
              • jsulmJ jsulm

                @BlueBreezy said in How I remove all data from a row in PySide2 without deleting the row:

                deleting a row with just that?

                You don't want to delete a row, right? You want to remove the content in all cells in a row if I understood you correctly. Using item(...) you get the item in the given cell and can then reset its content. For example if you have text in an item you can use https://doc.qt.io/qt-5/qtablewidgetitem.html#setText to set empty string in it.

                B Offline
                B Offline
                BlueBreezy
                wrote on last edited by
                #9

                @jsulm but I think I tried setting the row no no value before but whenever my code tries to put data into it it skips the row because it thinks that there is data there, here's an example

                window.tableWidget.setItem(0,0 ,QTableWidgetItem())
                
                jsulmJ 1 Reply Last reply
                0
                • B BlueBreezy

                  @jsulm but I think I tried setting the row no no value before but whenever my code tries to put data into it it skips the row because it thinks that there is data there, here's an example

                  window.tableWidget.setItem(0,0 ,QTableWidgetItem())
                  
                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @BlueBreezy I did not suggest to call setData. I suggested to call

                  window.tableWidget.item(row, col).setText("");
                  

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  B 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @BlueBreezy I did not suggest to call setData. I suggested to call

                    window.tableWidget.item(row, col).setText("");
                    
                    B Offline
                    B Offline
                    BlueBreezy
                    wrote on last edited by
                    #11

                    @jsulm oh right okay Let me try that

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      BlueBreezy
                      wrote on last edited by
                      #12

                      Thanks for the help let me just check my code to see if it my fault

                      1 Reply Last reply
                      0

                      • Login

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