Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2008
Temporarly disabling QSlider updates


Message 1 in thread

Dear Everybody,

I have a strange problem, I can't find a vital solution for...

I'm developing a media player which uses mplayer as its backend. Now I 
have a QSlider in my mainwindow, which enables seeking in the current 
movie. Ok so far, so good.

Now the procedure is following:
QProcess subclass starts mplayer. Waits for mplayer output (current 
second in the file). If it gets a new position, it emits a signal with 
this new time value. Now I convert this value to a percent value and set 
it as the new slider position value [sliderPos = (int) (newTimeInSec / 
totalTime)* 100] (the slider's minValue is 0 maxValue is 100).
The other way: if the user drags the slider, the valueChanged(int) 
signal is connected to a self-declared slot which tells mplayer to seek 
to the new position in the movie.

Problem 1)
setTracking is by default enabled but if I drag the slider than it gets 
in an infinite loop jumping between the old and the new time.

Problem 2)
disabling tracking causes the slider not to update its handle position 
on time change.

Tried with enabling tracking by default and then disabling it on 
sliderPressed() and re-enabling it on sliderReleased() but didn't work.
Tried also using the valueChanged(int) signal but same result as in 
problem 1...

Is there any handy solution to achieve updating of the slider and time 
value and vice versa? (i.e. update slider position as time elapses, and 
seek in the file after user has dragged the slider to a new position)
Or do I have to subclass QSlider and make my own TimeSeekSlider class?
If yes which slots should I reimplement and what way?

Thank you for your reply!

=========================
mfx-

project::mfx_
http://ferenc.stelcz.hu

--
 [ signature omitted ] 

Message 2 in thread

Ferenc Stelcz wrote:
[...]

hm.. weird.. it works.. haven't had to test it with a 60 min avi but 
with a 100 second long :)
Ok problem solved.

The next one is trickier.
The slider is updated every second. But if the user presses the slider 
and then drags it for _longer_ than a second, it jumps back to the 
position where the user started dragging it.
Can this be worked around somehow?

=========================
mfx-

project::mfx_
http://ferenc.stelcz.hu

--
 [ signature omitted ]