我有一个包含多个QTreeWidget的QComboBoxes。如何获得QComboBox中QTreeWidget中的当前文本?
我的QTreeWidget看起来是这样的:
ui->sensorTree
parent0
child0 QComboBox
child1 QComboBox
parent1
child0 QComboBox
child1 QComboBox
发布于 2013-09-11 19:37:39
将activated(QString)
信号从QComboBox
连接到您选择的自定义插槽。您可以使用单个插槽来处理所有已激活的命令,也可以使用多个插槽。下面的示例使用多个插槽。
connect(parent0->child0, SIGNAL(activated(QString)), this, SLOT(child00(QString)));
connect(parent0->child1, SIGNAL(activated(QString)), this, SLOT(child01(QString)));
connect(parent1->child0, SIGNAL(activated(QString)), this, SLOT(child10(QString)));
connect(parent1->child1, SIGNAL(activated(QString)), this, SLOT(child11(QString)));
您需要对在QTreeView
中生成的每个子部件重复这个过程,或者使用一个QSignalMapper
类来绑定所有信号。
https://stackoverflow.com/questions/18748633
复制相似问题