Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Transformation of co-ordinates on the graphics scene
faiszalkhan last edited by faiszalkhan
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);
/* Setting the view as the central widget */
/* Setting alignment of view to the top left */
ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
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.
I believe it is some transform issue between the view and the scene but I am not getting it.
What version of Qt are you using ?
On what OS ?
Can you show the current code you are using ?
faiszalkhan last edited by
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 ?
What would be nice is to have a minimal compilable example that shows that behaviour.