Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C PySide/pyQt单击垂直标题在QTableWidget中选择整行时发送什么信号_C_Qt_Python 3.x_Pyqt_Pyside - Fatal编程技术网

C PySide/pyQt单击垂直标题在QTableWidget中选择整行时发送什么信号

C PySide/pyQt单击垂直标题在QTableWidget中选择整行时发送什么信号,c,qt,python-3.x,pyqt,pyside,C,Qt,Python 3.x,Pyqt,Pyside,单击1选择a、b和c时,tableWidget发送什么信号 我只在C中找到了答案(我想这就是这个问题的答案),如下所示 - 1 2 3 1 a b c 2 d e f 3 g h i 我尝试在python中实现它,如下所示: connect( (QObject*) this->verticalHeader(), SIGNAL( sectionClicked(int) ), this, SLOT( rowSelection( int ) ) ); 但是它说verticalHeader没有

单击1选择a、b和c时,tableWidget发送什么信号

我只在C中找到了答案(我想这就是这个问题的答案),如下所示

- 1 2 3
1 a b c
2 d e f
3 g h i
我尝试在python中实现它,如下所示:

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

但是它说verticalHeader没有属性sectionClicked

我认为发出的信号是正确的,但您的代码不太正确。下面这个小例子似乎对我有用:

self.QTableWidget.verticalHeader.sectionClicked.connect(self.Test)
因此,从QTableWidget实例中,您需要通过调用
verticalHeader()
来获取垂直头对象,该对象的信号
部分已单击

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_())