Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Zoom In/Out QTableView with a frozen first column

Zoom In/Out QTableView with a frozen first column

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtableviewqgraphicsviewzoomlevelc++
5 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MarKSM Offline
    MarKSM Offline
    MarKS
    wrote on last edited by MarKS
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • MarKSM Offline
        MarKSM Offline
        MarKS
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why not implement a custom view that would handle that ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • MarKSM Offline
            MarKSM Offline
            MarKS
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved