This is my QSpinBox slot method:
void MainWindow::on_sbObjectSize_valueChanged(int arg1)
{
/*do something*/;
}
I need to distinguish when this value was changed by user (by typing value or click on arrows) and when it was changed from the code (eg. using ui->sbObjectSize->setValue(1)).
Is it possible to do this by overloading something, making own slot/signal or any other way?
Yes, you can do it by checking the value returned from
sender(). Let's say you have a button in your UI in your main window and clicking on the button changes the spin box value, thensender()'s value will be the address of the button pointer.qDebug()is really nice, since it will output other information available in yourQObjectthrough the metadata available. For instance you can give yourQObjecta name, and thenqDebug()will output that name.Here's a code snippet: