I found another solution:
{
Q_OBJECT
public:
NiceSlider
(int id, Qt
::Orientation orientation,
QWidget * parent
);
signals:
void valueChanged( int value, int id);
protected:
void sliderChange(SliderChange c)
{
emit valueChanged( this->value(), _id );
};
private:
int _id;
};
class NiceSlider : public QSlider
{
Q_OBJECT
public:
NiceSlider(int id, Qt::Orientation orientation, QWidget * parent);
signals:
void valueChanged( int value, int id);
protected:
void sliderChange(SliderChange c)
{
if(c == QAbstractSlider::SliderValueChange)
emit valueChanged( this->value(), _id );
QSlider::sliderChange(c);
};
private:
int _id;
};
To copy to clipboard, switch view to plain text mode
and in the constructor from earlier:
MyWidget::MyWidget()
{
for (int i=0 ; i<5 ; i++)
{
m_sliders.append( new NiceSlider ( i, Qt::Horizontal, this) );
QObject::connect( m_sliders
[i
],
SIGNAL(valueChanged
(int,
int)),
&m_view, SLOT(setDeformationFactor(int,int)));
}
}
MyWidget::MyWidget()
{
for (int i=0 ; i<5 ; i++)
{
m_sliders.append( new NiceSlider ( i, Qt::Horizontal, this) );
QObject::connect( m_sliders[i], SIGNAL(valueChanged(int,int)),
&m_view, SLOT(setDeformationFactor(int,int)));
}
}
To copy to clipboard, switch view to plain text mode
NICE, isn't it ?
Thank you all a lot!
Best regards,
Olli
Bookmarks