Reputation: 5420
I'm trying to use QSlider
to change the value of a variable,
#include <QSlider>
class MainThread : public QWidget{
Q_OBJECT
public:
MainThread(QWidget *parent=0);
private slots:
void setValue(double);
private:
QSlider *slider;
};
MainThread::MainThread(QWidget *parent):QWidget(parent){
slider = new QSlider(Qt::Horizontal,0);
connect(&slider, SIGNAL((slider->valueChanged())),
this, SLOT(setValue(double))); // here's my problem
...
}
My question is how can I connect the SIGNAL
of the slider to the setValue(double)
SLOT.
Thanks in advance.
Upvotes: 0
Views: 7010
Reputation: 608
slider is already a pointer, e.g. remove the '&'
connect( slider, SIGNAL((slider->valueChanged())), this, SLOT(setValue(double)) );
Edit: This won't work, since the signal has no argument. Rename the setValue(double) to setValue() and get the value from the slider with slider->value().
Upvotes: 2