I changed the widget to a QDoubleSpinBox which makes it easier to handle the values since I only want decimals at 0.5 steps.

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

But again when I try to access the value with the following code it does not return anything.

Qt Code:
  1. for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
  2. {
  3. QTreeWidgetItem *item = ui->treeWidget->topLevelItem(i);
  4. qDebug() << item->data(7, Qt::DisplayRole).toFloat();
  5. quantity += item->text(7).toFloat();
  6. }
To copy to clipboard, switch view to plain text mode 

Any ideas on how to access a value in a widget within the QTreeWidgetItem?

Thanks,

Pericles