this is a simplified version of my problem: I have 2 sliders that send information to another class/object:
// .h file
// .h file
QSlider *zXag[2];
To copy to clipboard, switch view to plain text mode
// .cpp file
zXag
[0] = new QSlider(Qt
::Vertical);
zXag
[1] = new QSlider(Qt
::Vertical);
// .cpp file
zXag[0] = new QSlider(Qt::Vertical);
zXag[1] = new QSlider(Qt::Vertical);
To copy to clipboard, switch view to plain text mode
My problem is with the connect. I want to do something like this:
connect(zXag[0], SIGNAL(valueChanged(int)), coin3dWidget, SLOT(setVertExag_0(int)));
connect(zXag[1], SIGNAL(valueChanged(int)), coin3dWidget, SLOT(setVertExag_1(int)));
connect(zXag[0], SIGNAL(valueChanged(int)), coin3dWidget, SLOT(setVertExag_0(int)));
connect(zXag[1], SIGNAL(valueChanged(int)), coin3dWidget, SLOT(setVertExag_1(int)));
To copy to clipboard, switch view to plain text mode
which works fine. But instead of 2 SLOT functions defined like above, I want something like:
setVertExag[0](int)
setVertExag[1](int)
In other words, just as I've an array of 2 slider objects, I'd like an array of 2 slot functions. I know you cannot make arrays of functions in C++, but hopefully you can at least see what I'm trying to do here and can suggest a solution. Below is the actual function that generates my sliders (and connects), in case this helps explain:
//function call
for(int a=0; a<Total_Num_Sliders; a++)
{
mkZXag(a);
}
//function
void Window::mkZXag(int compNUM)
{
zXag
[compNUM
] = new QSlider(Qt
::Vertical);
zXag[compNUM]->setSingleStep(1);
zXag[compNUM]->setTickInterval(10);
zXag
[compNUM
]->setTickPosition
(QSlider::TicksRight);
connect(zXag[compNUM], SIGNAL(valueChanged(int)), coinWidget, SLOT(setVExag/*???*/(int)));
}
//function call
for(int a=0; a<Total_Num_Sliders; a++)
{
mkZXag(a);
}
//function
void Window::mkZXag(int compNUM)
{
zXag[compNUM] = new QSlider(Qt::Vertical);
zXag[compNUM]->setSingleStep(1);
zXag[compNUM]->setTickInterval(10);
zXag[compNUM]->setTickPosition(QSlider::TicksRight);
connect(zXag[compNUM], SIGNAL(valueChanged(int)), coinWidget, SLOT(setVExag/*???*/(int)));
}
To copy to clipboard, switch view to plain text mode
Bookmarks