UrbKr
UrbKr

Reputation: 663

PySide/pyQt What signal is sent when selecting a whole row in QTableWidget by clicking on vertical header

- 1 2 3
1 a b c
2 d e f
3 g h i

When clicking on 1 to select a, b and c, what signal does tableWidget send.

I only found the answer (I think it's the answer to this question anyway) in C. Which is the following

connect( (QObject*) this->verticalHeader(), SIGNAL( sectionClicked(int) ), this, SLOT( rowSelection( int ) ) );

I tried to implement it in to python like so:

self.QTableWidget.verticalHeader.sectionClicked.connect(self.Test)

But it says that verticalHeader has no attribute sectionClicked.

Upvotes: 2

Views: 2345

Answers (1)

brm
brm

Reputation: 3816

I think the signal that's emitted is correct, but your code is not quite right. The following small example seems to work for me:

from PySide import QtGui
import sys

class W(QtGui.QTableWidget):
    def __init__(self):
        super(W,self).__init__(3, 3)

        self.verticalHeader().sectionClicked.connect(self.onSectionClicked)

    def onSectionClicked(self, logicalIndex):
        print("onSectionClicked:", logicalIndex)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    w = W()
    w.show()
    sys.exit(app.exec_())

So, from the QTableWidget instance, you need to obtain the vertical header object by calling verticalHeader(), which has the signal sectionClicked you mentioned.

Upvotes: 3

Related Questions