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. QGrahicsView "translate" has no effect
Forum Updated to NodeBB v4.3 + New Features

QGrahicsView "translate" has no effect

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.2k Views 2 Watching
  • 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.
  • L Offline
    L Offline
    Linux777
    wrote on last edited by
    #1

    Hello!
    I have my custom class derived from QGrahicsView.

    void my_view::wheelEvent(QWheelEvent *event)
    {
    	QTransform tf;
    	tf.translate(offset.x(), offset.y());
    	tf.scale(current_scale, current_scale);
    	tf.rotate(r);
    	setTransform(tf, false);
    }
    

    Scale - working, rotate - excellent, translate - absolutely no effect! but offset.x/y is changing.

    I tried many many things such as:

    • setAlignment(0);
    • setTransformationAnchor(QGraphicsView::NoAnchor); + setResizeAnchor(QGraphicsView::NoAnchor);
    • centerOn(event->pos());

    I just want to view different parts of my scene more detailed with higher zoom. Please help me, I'm so much confused and angry that dumb primitive action just move view is not working at all... =(

    Which highly intelligent options of QGraphicView I should turn off to make this thing just do what I want without any implicit impacts on my "orders"?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      My first idea is that the scene is too small. Do you have scrollbars, and if so, can you navigate using them?

      Other things to try: fitInView, ensureVisible

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        The scene is automatically translated according to the view's alignment settings. This is done so that the scrollbars work as expected in most use cases. To achieve what you want the easiest way is to set alignment to AlignLeft and AlignTop, make the sceneRect the same size as the view and then don't apply translations to the view but to the sceneRect (= increase / decrease the x and y of the sceneRect). And always disable the scrollbars.

        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