Zoom In/Out QTableView with a frozen first column

  • I am trying to create a timeline like layout for my project. My timeline layout resembles something like we use for Audio and Video editing tools. Right now i am using QGraphicsView and have implemented something like this:

    void TimeLine::wheelEvent(QWheelEvent* event)
        // Scale the view / do the zoom
        double scaleFactor = 1.15;
        if (event->delta() > 0)
            // Zoom in
            scale(scaleFactor, scaleFactor);
            // Zooming out
            scale(1.0 / scaleFactor, 1.0 / scaleFactor);

    But this code zooms in/out the whole of QTableView along with the scrollbars.

    Keeping in mind i have implemented my QTableView with a frozenColumn as documented here

    Just for reference my TimeLine with a horizontal slider looks something like this:

    My requirement is bit specific:

    • How do i implement zoom in/out function only on the table view (NOT frozenColumn) i.e. wheelEvent should trigger scaling of column widths, horizontal header and horizontal scroll bar as well.

    I would appreciate some new ideas.

  • Lifetime Qt Champion


    You seem to mix QTableView and QGraphicsView. Why the QGraphicsView ?

  • Hi,

    I am using a QGraphicsRectItem on top of QTableView which acts like a SeekBar (horizontal slider). So i have put QTableView and QGraphicsRectItem in one QGraphicsScene. I posted a question on SOV regarding this . Should give you an idea what i am trying to achieve. I am not sure if this is a good approach but if you can share some ideas would be nice.

  • Lifetime Qt Champion

    Why not implement a custom view that would handle that ?

  • Do you mean custom graphicsView or tableView? If custom graphics view wouldn't it be too hard to reimplement everything? Any links or example would help.

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