On Windows, if I open a project in QGIS then the project file name appears in the title bar.
If I do the same thing in PyQGIS using the following code the title bar does not change.
from PyQt4.QtCore import QFileInfo QgsProject.instance().read(QFileInfo("C:/FilePath.qgs"))
But the project loads fine, I can see my project data and if I click the save button then the file name appears in the title bar.
I was wondering if there was a bridge or some hack needed to get the file name to appear. I need this because my client has similar looking projects and uses the file name to know that my code has loaded the right one for them. Of course I could show it to them another way like in the message bar but seeing as opened projects normally get their file name in the title bar I thought I should be keeping to this 'standard' way of doing it.
Things I've tried...
Saving the file via:
Does save the file but doesn't update the title bar.
Canvas bridge code
from qgis.gui import * canvas = QgsMapCanvas() bridge = QgsLayerTreeMapCanvasBridge( \ QgsProject.instance().layerTreeRoot(), canvas)
Also didn't help.
How can I get the file name to appear in the title bar of QGIS when using .read() ?