Reputation: 5375
I have a QTreeWidget that contains several QComboBoxes. How can I get the current text of a QComboBox that is in the QTreeWidget?
My QTreeWidget looks something like this:
ui->sensorTree
parent0
child0 QComboBox
child1 QComboBox
parent1
child0 QComboBox
child1 QComboBox
Upvotes: 0
Views: 196
Reputation: 4335
Connect the activated(QString)
signal from the QComboBox
to a custom slot of your choosing. You can either use a single slot to handle all the activated commands, or multiple slots. My example below uses multiple slots.
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)));
You'll need to repeat the process for each child widget that you make in the QTreeView
, or use a QSignalMapper
class to bundle all the signals.
Upvotes: 1