Domanda

//in my .h file i have:
void on_doubleSpinBox_test_valueChanged(double t);

//in my .cpp(mainwindow):
void MainWindow::on_doubleSpinBox_test_valueChanged(double t)
{
    ui->lineEdit_test->setText(QString::number((double) t/2));
}

My problem is that when i set the value for lineEdit in SpinBox everything works, however in doubleSpinBox there is no message sent (changing value doesn't work). What am i doing wrong? How to make this method to work?

È stato utile?

Soluzione

The valueFromText and textFromValue methods might do what you want. They allow displaying the value of the spin box in a customized format, such as always displaying half the value of the spin box as in your code above.

http://doc.trolltech.com/4.7/qdoublespinbox.html#valueFromText http://doc.trolltech.com/4.7/qdoublespinbox.html#textFromValue

A sample of how to use the methods is in the class QSpinBox and they are used the same in QDoubleSpinBox. http://doc.trolltech.com/4.7/qspinbox.html#subclassing-qspinbox

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top