2

Upon starting Qgis, a (currently under construction) plugin needs a means of checking the current project/legend/registry.

This checksum would ideally occur upon startup automatically. As the plugin has several buttons which function based on the current project's save location (if one exists).

Example:

Rather then having to click a button in the plugin toolbar every time Qgis opens, the directory resource could be available to the plugin upon initiation and thus establish the credibility of the current project with respect to the plugins functionality.

Important Note:

[The button itself currently has no issue finding the working project directory after startup. Yet since the qgis-plugins seem to be loaded before the 'last saved' project in Qgis initialization - I have not been able to find a means of automating this process]

2
  • I'm confused. What do you need to know. The current project directory?
    – Nathan W
    Mar 12, 2015 at 13:08
  • Yes. Nabbing the current project dir. is now a manual operation via a button click function along the lines of: "projectDirectory = QgsProject.instance().readPath('./')" after qgis fully loads the plugins and project itself. I'm wondering if there is a means of implementing this within the plugin initiation - so that it is automatically accomplished during qgis-start?
    – Katalpa
    Mar 12, 2015 at 13:18

1 Answer 1

6

Connect to the project read signal to know when a project is loaded

def project_loaded(dom):
    print QgsProject.instance().readPath("./")

QgsProject.instance().readProject.connect(project_loaded)
2
  • That looks to be exactly the signal I (mistakenly) overlooked. Although I am getting an attribute error stating 'PyQt4.QtCore.pyqtSignal' object has no attribute 'connect' ?
    – Katalpa
    Mar 12, 2015 at 14:13
  • 1
    Establishing an 'instance()' did it: "QgsProject.instance().readProject.connect(self.toolBarEnabling)". :)
    – Katalpa
    Mar 12, 2015 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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