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?

    Cheers,



  • 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) :
    QSlider(parent)
    {
    scale = 1;
    setTickInterval(1000);
    setTickPosition(QSlider::TicksBelow);
    }

    void SliderTimeLine::paintEvent ( QPaintEvent * event )
    {
    QPainter painter(this);
    painter.scale(scale,1);
    // paint the parent with painter
    }
    void SliderTimeLine::wheelEvent ( QWheelEvent * event )
    {
    qDebug() << "wheel event";
    scale+=(event->delta()/100);
    update();
    }
    @

    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:
    @
    this->parent()->update();
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.