I am trying to build a function that takes a (qt) Type as a parameter and uses it to find children. My function looks like this:
template <typename QType>
void MyClass::activateElements(QWidget *widget, QType t)
{
QList<QType *> buttons = widget->findChildren(t);
foreach( QType *button, buttons )
{
buttons->setEnabled(true);
}
}
I have also tried
template <typename QType>
void MyClass::activateElements(QWidget *widget, QType)
{
QList<QType *> buttons = (* widget).findChildren<QType *>();
foreach( QType *button, buttons )
{
button->setEnabled(true);
}
}
I instantiate an object of the class that uses this function in another class. There I try to use it like this:
QDoubleSpinBox x;
object_of_my_class->activateElements(correctWidget, x);
At this point I get stuck because I get the following error:
error: ‘QDoubleSpinBox::QDoubleSpinBox(const QDoubleSpinBox&)’ is private
Q_DISABLE_COPY(QDoubleSpinBox)
How would I handle this problem, that QDoubleSpinBox and others are private? Have I approached how to build the function wrong or am I just using it incorrectly? Is there even a way to do it?