【发布时间】:2016-08-02 09:23:17
【问题描述】:
我开始从事一个需要使用 TableView 的项目。我的表有 3 列,最后一列有一个组合框。使用委托我设法设置组合框并在组合框的索引状态更改时检索信号。问题是我无法从女巫组合框中识别出信号是从哪里发出的。
如果我向 mainWindow 发出组合框的 QString 信号,这似乎很糟糕。我正在考虑一种解决方案,将每行的索引插入到组合框中。类似行 + 名称。
我使用另一篇文章的建议发起连接,例如:
signals:
void boxDataChanged(const int & str);
在创建编辑器中:
QComboBox * editor = new QComboBox(parent);
editor->addItem("This");
editor->addItem("is");
editor->addItem("nice");
connect(editor, SIGNAL(currentIndexChanged(int)), this, SIGNAL(boxDataChanged(int)));
return editor;
并称其为:
connect(mydelegate, &Delegate::boxDataChanged, [=](const int & str)
{
qDebug() << str;
});
这很好用,但我还需要从女巫行知道这即将到来。
【问题讨论】: