Time Line zoom

  • Hello,

    I want to achieve a classic time line for the duration of a video.
    I want to be able to zoom in this line to have more accurate time.

    Which Qt widgets would you use to achieve that? Is there something native to scale and display the values depending or how much you zoomed in or should it be completely manual?


  • Hi,
    You could use a QSlider and use the indicator position where the video is.
    The class you create could inherit the QSlider and catch the event where the zoom is made with (probably mousescrollwheel??). Then set the min and max value accordingly.

  • Hello,
    Yes I need to do with wheel event.
    However, now I have an issue, here is my code :

    #include "SliderTimeLine.h"
    #include <QPainter>
    #include <QWheelEvent>
    #include <QDebug>

    SliderTimeLine::SliderTimeLine(QWidget *parent) :
    scale = 1;

    void SliderTimeLine::paintEvent ( QPaintEvent * event )
    QPainter painter(this);
    // paint the parent with painter
    void SliderTimeLine::wheelEvent ( QWheelEvent * event )
    qDebug() << "wheel event";

    I need to find a way to draw the parent slider with the scaled painter, and I cant figure how to achieve that :(

    Any idea?

  • The child is always capable of sending a signal to the parent (if connected from the parent).
    Also (not real OO programming, but still) you are able to call a parent function by the QObject function parent().
    So something like this:

Log in to reply