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. [Solved] QTableView (QTableWidget) removeRow removes several rows
Forum Updated to NodeBB v4.3 + New Features

[Solved] QTableView (QTableWidget) removeRow removes several rows

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.4k Views 1 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.
  • F Offline
    F Offline
    Fatuo
    wrote on last edited by
    #1

    I have this code:

    @
    self.connect(table, SIGNAL('cellPressed(int, int)'), self.deleteRowClicked)
    ....
    def deleteRowClicked(self, row, column):
    if column == 0:
    table = self.sender()
    table.removeRow(row)
    return True

    @

    So if the user clicks on the cell of the first column the row is removed.

    The problem I have is that this code remove not only that row, also all rows behind it. :?

    What I'm doing bad???

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you sure your slot is not called twice rather than removing two rows ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fatuo
        wrote on last edited by
        #3

        Yes it is called, not twice, several times! , why???

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Right now, I don't know. Did you check the row/col values ? Are you keeping the mouse down when pressing your mouse button ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Fatuo
            wrote on last edited by
            #5

            Tried to do it for several ways, in one table the event is called twice, by the other hand a similar table, the event is called like ten times.

            :????

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Might be propagating to the next cell since you delete the one under the cursors (that's just an idea nothing more)

              Personally, I wouldn't use cellPressed to delete a row, rather cellClicked or cellDoubleClicked.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Fatuo
                wrote on last edited by
                #7

                I finally found the problem, the connect method was called each time a row is add to the TableWidget, so when the signal arrives the slot is called once per connect.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  That's a classic :)

                  Most of the time connections like this one should be done in the widget's constructor

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Fatuo
                    wrote on last edited by
                    #9

                    Still working wit QT designer so the constructor is changing frecuently. On the final version i will put it there all the connections.

                    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