我在 GUI 中插入了 QTableView
并设置 selectionMode = SingleSelection
、 selectionBehavior = SelectRows
。
我想通过更改所选行将我的插槽连接到信号(选择已更改或另一个信号)。
请查看我的代码:
connect(ui->tableView->selectionModel(),
SIGNAL( selectionChanged(const QItemSelection&,
const QItemSelection&)), this ,SLOT(myslot()));
我收到一条错误消息:
QObject::connect: Cannot connect (null)::selectionChanged(const QItemSelection&, const QItemSelection&) to Info::myslot
最佳答案
没有看到minimal, reproducible example很难确定问题的真正根源,但消息......
QObject::connect: Cannot connect (null)::selectionChanged(const QItemSelection&, const QItemSelection&) to Info::myslot
表明该表达式...
ui->tableView->selectionModel()
计算结果为空指针。在建立连接之前,您需要确保您的 UI 已设置完毕。
关于c++ - 如何连接QTableView选择改变的信号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60660512/