Overloading signal possible? Or adding new signals to base classes?
-
Hello, recently i created a widget with QT designer.
This widget contains some spinboxes as well as a child widget. Now i want the spinboxes to tell the child widget two things:
a) that their value changed to int i and b) their own id(so the child widget knows which spinbox emitted the signal) thus i need a signal thats similar to this: void valueChanged(int,int). Of course normal spinboxes dont have such a thing so i wondered if it is possible to either change the signal or to add another signal which does the things i descriped.
Thank you for any help :) -
-
Here are some code snippets for what iunknwn was describing.
Setup spinboxes
@
m_spinbox1 = new QSpinBox(this);
m_spinbox2 = new QSpinBox(this);
m_spinbox3 = new QSpinBox(this);connect(m_spinbox1, SIGNAL(valueChanged(int)), this, SLOT(onChanged(int)));
connect(m_spinbox2, SIGNAL(valueChanged(int)), this, SLOT(onChanged(int)));
connect(m_spinbox3, SIGNAL(valueChanged(int)), this, SLOT(onChanged(int)));
@Use sender() to identify spinbox
@
void onChanged(int value)
{
QSpinBox spinBox = qobject_cast<QSpinBox>(sender());
if (spinBox == m_spinBox1) ...
else if (spinBox == m_spinBox1) ...
else if (spinBox == m_spinBox1) ...
}
@ -
thank you for your fast answer, i changed my program accordingly, but now im getting this "error"(the program still compiles but the connections wont work):
"No such slot QWidget::statChanged(int) in ./ui_mainwindow.h:211
Object::connect: (sender name: 'Stat1Box')
Object::connect: (receiver name: 'widget')"I created an extra class to draw within widget and told QT designer to use the class for the widget(that part works). But when i added Slots to said class(and connected the value change from my spinboxes with some of the slots) i got this error.
-
Ok i fixed it.
At first i had used the QT designer connector to connect the spinboxes with the child widget, but this didnt work(i dont know why, maybe i didnt tell the program properly that the child widget actually is a child).
Then i did it manually via connect(ui->spinbox,...,ui->widget...)
that worked.
thank you all :)How do i tell QT that i created a child widget when using the desiger to create it? I just placed one within the original widget form and thought it is automatically a child, but this might not be true.