3

I'm currently working on QGIS plugin as part of a school project. One feature of this plugin is going to be the possibility to transform coordinates from one EPSG code to another.

Therefore it would be the most useful and user-friendly way to let the user open the "project properties" dialog by clicking a specific button in the plugin, in this dialog he chooses the CRS he wants to use and on closing the dialog the chosen value is taken to the plugin code so I can use it for the transformation itself.

I already searched in the QGIS API but without any success. I made it to open some other menus via the "iface" reference in my code, but unfortunately not the one you open by clicking in QGIS at to bottom right corner, left of the bubble which opens the message view.

Hope I made my problem as understandable as possible, if not feel free to ask more details.

1

I finally managed to find an even better solution for my problem described above. After clicking a specific button in my plugin, following method opens not the project properties dialog, but a dialog which provides the possibility to filter and select a CRS. On closing the dialog via the "OK" button, various text fields of the plugins are filled with the Athority ID and the Coordinate Reference System.

    def __button_from_clicked(self):
    selector = QgsGenericProjectionSelector()
    parent = self.dlg.pos()
    selector.move(parent)
    authId = None
    desc = None
    if selector.exec_():
        authId = selector.selectedAuthId()
        proj = QgsCoordinateReferenceSystem()
        proj.createFromSrsId(selector.selectedCrsId())
        self.proj_from = proj
        desc = proj.description()

    if authId is not None and desc is not None:
        self.dlg.lineEdit_autid_to.setText(authId)
        self.dlg.textEdit_to.setText(desc)
  • Don't forget to click the green-faded tick on the left-hand side of your answer to accept it ;) – Joseph Jan 18 '17 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.