Qt在QTreeWidget中获取QComboBox-> currentText

时间:2013-09-11 18:27:43

标签: qt qtreewidget qcombobox

我有一个包含几个QComboBox的QTreeWidget。如何获取QTreeWidget中的QComboBox的当前文本?

我的QTreeWidget看起来像这样:

ui->sensorTree

parent0
    child0    QComboBox
    child1    QComboBox

parent1
    child0    QComboBox
    child1    QComboBox

1 个答案:

答案 0 :(得分:1)

将来自activated(QString)的{​​{1}}信号连接到您选择的自定义广告位。您可以使用单个插槽来处理所有已激活的命令,也可以使用多个插槽。我下面的例子使用多个插槽。

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类捆绑所有信号。

相关问题