I'm trying to set the initial position of my QGIS plugin dialog. I'm using .setGeometry() but the problem is that I don't know how to get coordinates. I want to set the initial position in the top corner of the canvas in QGIS (like the image below). I've tried this but it does not work.
self.dlg = SetZoomDialog()
canvasCenter = iface.mapCanvas().extent().center()
canvasToGlobal = iface.mapCanvas().mapToGlobal(QPoint(int(canvasCenter.x())/2, int(canvasCenter.y())/2))
x= canvasToGlobal.x()
y= canvasToGlobal.y()
self.dlg.setGeometry(x,y,width,height)
I tried also this canvasToGlobal = QgsMapTool(iface.mapCanvas()).toCanvasCoordinates(canvasCenter)
but still I don't understand how to convert canvas coordinates to screen coordinates.