11
我有一个QTableView
,我需要从中获取selectionChanged事件。我似乎无法获得连接工作。我有:QTableView selectionChanged
MyWidget.h
...
protected slots:
void slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected);
private:
QTableView table;
...
MyWidget.cpp
...
connect(
table->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)),
this,
SLOT(slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected))
);
...
在运行时,我得到 “没有这样的信号” 的错误。
+1你似乎已经忘记了你的声明中的“this”(SIGNAL和SLOTS之间的参数)tho,是不是? – 2010-03-04 07:15:55
安迪,我想我可以把这一点点出来。 Kaleb,谢谢你,先生!像宝石一样工作:) – 2010-03-04 14:41:09
@安迪 - 不,我故意将它遗漏了。只要收件人是“this”,上面的语法就更加简洁和等效。有两个连接,一个连接实例方法(我使用)和一个静态方法。有关更多信息,请参阅文档。 – 2010-03-04 18:08:25