PDA

View Full Version : Retaining a spinbox value



positive_4_life
19th November 2009, 16:20
Hello, I have a minor problem which confounds me:

I have a UI which contains a spinbox and a button. The user can choose whatever value can be used in the spinbox's range, but I want it to hold the currently selected value of the spinbox when the button is clicked and transfer it to another function. I have this so far:



mainwidget->connect( strt_rcrding_btn, SIGNAL(clicked()), loc_spinbox, SLOT(value() ) ); //hold value of spinbox

mainwidget->connect (loc_spinbox,SIGNAL(valueChanged(int) ), &response, SLOT( write_dat_attrib(int) ) ); //and puts it to file


But QSpinBox::value() is not a valid slot so is there another slot I could use which emits the valueChanged signal? Or is there another way I could code this?

Thanks

Lykurg
19th November 2009, 17:07
You have to make your own slot:

QObject::connect( strt_rcrding_btn, SIGNAL(clicked()), this, SLOT(yourSlot()));
//...
void XYZ::yourSlot()
{
response->write_dat_attrib(loc_spinbox->value());
}

positive_4_life
19th November 2009, 17:36
Thanks a lot. That solved my problem.