QSlider is not sliding

2.4k views Asked by At

Somehow my QSlider is not sliding. I am only able to click on the slider and then the slider changes his position. I have checked with examples but everything seems to be the same.

Here is one of my QSliders:

QSlider  *obj_scale_x= new QSlider(Qt::Horizontal);
obj_scale_x->setValue(10);
obj_scale_x->setToolTip(tr("Scale object"));
obj_scale_x->setRange(1,50);
obj_scale_x->setTickPosition(QSlider::TicksAbove);
connect(obj_scale_x, SIGNAL(valueChanged(int)), this, SLOT(objScale_x(int)));

I thought the problem might be the mouse. But this is not working either.

void OpenGLScene::mousePressEvent(QMouseEvent *event)
{ 
    lastPos = event->pos();
}

void OpenGLScene::mouseMoveEvent(QMouseEvent *event)
{
    lastPos = event->pos();
}

I am definining the Slider in QGraphicsScene-based class. it might be this, but I am at my wit's end.

2

There are 2 answers

0
rigo On

Maybe the answer to your problem is:

obj_scale_x->setTracking(true);
0
rsp1984 On

Make sure you don't have an eventFilter() defined for an object higher up in the UI hierarchy, and if you do, make sure it doesn't "swallow" the event in case it doesn't react to the event directly (i.e. call BaseClass::eventFilter(obj, event) in that case).

That solved the problem for me.