我有一个QTableView我需要从中获取selectionChanged事件.我似乎无法使连接工作.我有:
MyWidget.h
...
protected slots:
void slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected);
private:
QTableView table;
Run Code Online (Sandbox Code Playgroud)
...
MyWidget.cpp
...
connect(
table->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)),
this,
SLOT(slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected))
);
Run Code Online (Sandbox Code Playgroud)
...
在运行时,我得到"No such Signal"错误.
Kal*_*son 16
您需要从SIGNAL和SLOT宏中删除变量名称:
connect(
table->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(slotLoadTransaction(const QItemSelection &, const QItemSelection &))
);
Run Code Online (Sandbox Code Playgroud)
Connect实际上是在查看函数签名,变量名称会让人感到困惑.