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. Transformation of co-ordinates on the graphics scene
Forum Updated to NodeBB v4.3 + New Features

Transformation of co-ordinates on the graphics scene

Scheduled Pinned Locked Moved Solved General and Desktop
graphics scenegraphics viewgraphicsitemtransforms pain
4 Posts 2 Posters 839 Views 1 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.
  • faiszalkhanF Offline
    faiszalkhanF Offline
    faiszalkhan
    wrote on last edited by faiszalkhan
    #1

    I have QGraphicsView as central widget of QMainWindow
    I am binding scene and the view as follows,

    /* Constructor of mainWindow */
    scene = new Canvas(&strContextMenu, this);
    ui->graphicsView->setScene(scene);

    /* Setting the view as the central widget */
    setCentralWidget(ui->graphicsView);

    /* Setting alignment of view to the top left */
    ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop);

    Problem Statement:
    When I paint a graphics Item on the scene(Position is the click of the mice), only the first Item is drawn on the top left of the view. Subsequent graphic Items of the same type do not experience this and are drawn where intended(position of the click of the mice)

    Requirement is to draw the items wherever mice is clicked which is achieved by using scene->setSceneRect(QRectF(0, 0, 1000, 700)) which
    I don't want to do as I want the size of the scene to be hardcoded.

    I have tried using the following but it doesn't seem to work.
    ui->graphicsView->setTransformationAnchor(QGraphicsView::NoAnchor);
    ui->graphicsView->resetTransform();

    I believe it is some transform issue between the view and the scene but I am not getting it.

    Please help!

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

      Hi,

      What version of Qt are you using ?
      On what OS ?
      Can you show the current code you are using ?

      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
      • faiszalkhanF Offline
        faiszalkhanF Offline
        faiszalkhan
        wrote on last edited by
        #3

        Hi, I am on Qt 5.9. Operating System MacOS Mojave. The code I shared above is the constructor of the mainWindow and where I see the problem.

        Is there any specific snippet you'd like to see ?

        Thanks.

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

          What would be nice is to have a minimal compilable example that shows that behaviour.

          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

          • Login

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