2010-06-29 355 views

回答

3

您有几个不同的选项。最直接的为你问什么是使用与该按钮相关的QHeaderView

// you could also use verticalHeader() 
connect(tableWidget->horizontalHeader(), SIGNAL(sectionClicked(int)), ...); 

另一种选择是听selection model

connect(tableWidget->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), ...) 

但是,此选项将要求您检查选择是否仅选择了整行,除非您的SelectionMode防止它被其他方式阻止。

+0

不确定为什么,但它根本没有发出'SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))'信号。相反,使用'SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&))'为我做了诀窍。 – Claudiu 2017-11-14 17:14:29

0

这是对我工作:

connect(tableWidget->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), ...) 

我上心从here