PDA

View Full Version : Help Qslider



superteny
7th July 2009, 16:54
Hi guys!!!
i have a problem using qslider. I wanna know if there is any way to know the exact value when i click anywhere in the qslider. That is, i click inside the qslider and i want to know wich is the value that i have clicked (inside the range of qslider).

is there any signal or similar to catch it??

Thanks a lot and sorry if the question is not clear at all, but i dont know how i can explain.

codeslicer
7th July 2009, 16:59
I might not understand what you mean, but the documentation should have the answer.

Don't forget that QSlider inherits QAbstractSlider! QAbstractSlider::valueChanged() may be what you're looking for.

And QAbstractSlider::sliderPosition() (http://doc.trolltech.com/4.5/qabstractslider.html#sliderPosition-prop) is the int value.

superteny
7th July 2009, 17:30
I have read the doc and i dont find any answer to my problem. i want to click inside the qslider and get the position of the slider that i click. i dont want to know the slider position, i want to know the position i click inside the slider range.
Sorry for the explanation.

codeslicer
7th July 2009, 18:08
But, when you click somewhere in the slider range, the slider value changes to the place you clicked. You can turn that feature on and off by changing the tracking() property (setTracking(bool)). So, tracking, on by default, changes the value every time the location of the slider is changed.

nish
8th July 2009, 03:22
I have read the doc and i dont find any answer to my problem. i want to click inside the qslider and get the position of the slider that i click. i dont want to know the slider position, i want to know the position i click inside the slider range.
Sorry for the explanation.

if i understood correctly.. u need to reimplement


void mousePressEvent(QMouseEvent *e)
{
QPoint position = e->pos();

QSlider::mousePressEvent(e);
}

if you do not want to inherit qslider. then put a QObject::eventFilter() in the parent widget and catch the mouse press .

superteny
9th July 2009, 11:03
thanks for your help. i reimplement mousepressed and other mouse event and get the solution.