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) { setTransformationAnchor(QGraphicsView::AnchorUnderMouse); // Scale the view / do the zoom double scaleFactor = 1.15; if (event->delta() > 0) { // Zoom in scale(scaleFactor, scaleFactor); } else { // 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:
(https://stackoverflow.com/questions/51248086/adding-horizontal-slider-to-qtablewidget/51249563?noredirect=1#comment89479971_51249563)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.
-
Hi,
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.
-
Why not implement a custom view that would handle that ?