1

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.

buddy
  • 821
  • 2
  • 12
  • 30
  • 1
    Well, we'll need some more information here. Do you have a code sample of your problem? – mmoment Jan 12 '12 at 23:35
  • right now your event flow is `SLider -> Someobject` so it perfectly make sense that it slide only if you click on it. Anyway really vague, please explain. – UmNyobe Jan 13 '12 at 10:31
  • how are you going to slide without clicking? keyboard? smth else? what _exactly_ does not work? – Lol4t0 Jan 13 '12 at 12:00
  • It is only possible to move the slider by clicking with abrupt movements. It is not possible to press down the mousebutton and achieve a smooth movement.The functionality works. The only thing that is not working is the smooth slide movement. I can only jump with the mouse to new slider positions. – buddy Jan 13 '12 at 23:08

2 Answers2

1

Maybe the answer to your problem is:

obj_scale_x->setTracking(true);
rigo
  • 56
  • 1
  • 2
0

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.

rsp1984
  • 1,877
  • 21
  • 23