开发者

selecting or deselecting a row in qt4

how to set 开发者_JAVA技巧or reset a counter when row of table is selected or deselected using mouseevent in qt4?


Assuming you are using a QTableView or QTableWidget for your table, you can receive a Qt-signal whenever the set of selected cells has changed by doing this:

connect(theTable.selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(SelectionWasChanged(const QItemSelection &, const QItemSelection &)));

Note that that will work whether the selection was changed via the mouse, keyboard, or some other means. If you really need the callback only when the selection was made via a QMouseEvent, you could probably implement that by overriding QTableView::mousePressEvent() and/or QTableView::mouseReleaseEvent() in a subclass and setting a flag to true before calling up to the superclass (and setting it false again afterwards) and checking the flag within your SelectionWasChanged() slot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜