I have a QTreeWidget in which I made an addRoot function and an addChild function.

In the addRoot I want one column of the widget to be a doublespinbox and so I call it with the following code:

Qt Code:
  1. // Testing spinboxes
  2. QDoubleSpinBox *quantitySpinBox = new QDoubleSpinBox();
  3. quantitySpinBox->setDecimals(1);
  4. quantitySpinBox->setSingleStep(0.5);
  5. ui->treeWidget->setItemWidget(itm, 7, quantitySpinBox);
  6.  
  7. connect(quantitySpinBox, SIGNAL(editingFinished()), this, SLOT(planQuantity()));
To copy to clipboard, switch view to plain text mode 

The spinbox appears correctly and works fine in the widget.

The problem arises when I try to access the values in the widget.

I use the following debugging code to see what the values are in the spinboxes.

Qt Code:
  1. qDebug() << item->data(7, Qt::DisplayRole).toFloat();
To copy to clipboard, switch view to plain text mode 

The result is all 0. Even though I change values throughout the cells it is always 0.

Is there something that I am doing wrong? How can I access the value set inside the spinbox?

Any help will be greatly appreciated because I am stuck here not going anywhere without those values.

Thanks,

Pericles