PDA

View Full Version : QSpinBox within a QTableWidget



deadbird
21st December 2010, 21:29
Hi there ;)
I've got a little issue using a QTableWidget. I got one, filles with coordinates (x, y, and z). EAch coordinate is a QSpinBox.
The problem is that I want a function to be launched each time a QSPinBox value is modified. I tried this:

//column zero
QTableWidgetItem *activate = new QTableWidgetItem("Activate");
activate->setFlags(Qt::ItemIsUserCheckable);
activate->setCheckState(Qt::Checked);

//column X
QDoubleSpinBox *x = new QDoubleSpinBox();
connect(x, SIGNAL(valueChanged(double)), this, SLOT(somethingChanged(double)));
x->setValue(0.0);

//column Y
QDoubleSpinBox *y = new QDoubleSpinBox();
connect(y, SIGNAL(valueChanged(double)), this, SLOT(somethingChanged(double)));
y->setValue(0.0);

//column Z
QDoubleSpinBox *z = new QDoubleSpinBox();
connect(z, SIGNAL(valueChanged(double)), this, SLOT(somethingChanged(double)));
z->setValue(0.0);

//add a line
ui.listPoints->setRowCount(n_rows+1);

//change its height & color
ui.listPoints->setRowHeight(n_rows, 20);

ui.listPoints->setItem(n_rows, 0, activate);
ui.listPoints->setCellWidget(n_rows, 1, x);
ui.listPoints->setCellWidget(n_rows, 2, y);
ui.listPoints->setCellWidget(n_rows, 3, z);


But somethingChanged is never called. I also tried to connect QTableWidget's itemChanged to it, didn't helped.
Can someone help?