0

I have a QTreeWidget with several QComboBoxes as QTreeWidgetItems. I am trying to find a way to get the current QTreeWidget row of the selected QComboBox. ui->sensorTree is the QTreeWidget. My tree looks something like this:

parent0
    child0    QComboBox0
    child1    QComboBox1
parent1
    child0    QComboBox0    QComboBox0
    child1    QComboBox1    QComboBox1

So if QComboBox0 was selected I would want to return 0.

Update:

int index = ui->sensorTree->currentIndex().row();

This gives me the correct row. The problem now is that the row does not have to be selected to change the QComboBox. What I need is to connect QComboBox.indexChanged to pass the row the ComboBox is in, and the current ComboBox text of all ComboBoxes in the row.

4

1 回答 1

0

我让它工作。我最终只是创建了自己的继承 QComboBox 的自定义类,并且我只是添加了一个构造函数,该构造函数传入了一个具有行号的额外参数。然后我创建了一个自定义信号,它传递了组合框的当前文本和从构造函数传入的行数据中获得的行。

于 2013-09-12T19:56:24.163 回答