[Qgis-developer] Connecting composer closure with another window focus

Vincent Damoy vincent.damoy at espaces-naturels.fr
Mon Dec 16 06:02:56 PST 2013


Hi all,

I'm running QGIS 2.0.1 on Ubuntu 12.04, 64 bits (installed with 
ubuntugis-unstable repository).

I've created a form, which shows a composer when I click on a button.
This form stays active while the composer is showed, but is located 
behind the QGIS main window.
I'd like it to come back in front of the screen when the composer is 
closed by user.

After several web searchs and tests, it seems that the following 
function works :

/def operationOnTop(self): //
//     self.raise_() //
//     self.activateWindow()/

My problem is to connect a « composer closed » signal with this function.
I think the signal should be QgsComposerView.composerViewHide. I'm right ?

* I tried to connect it with the above slot  :

/QgsComposerView.composerViewHide.connect(self.operationOnTop)/

But QGIS returns :
AttributeError: 'PyQt4.QtCore.pyqtSignal' object has no attribute 'connect'
I can't understand this error message : all signals should have 
« connect » attribute, right ?

* Trying with the old « connect » way :

/self.connect(QgsComposerView(), QtCore.SIGNAL('composerViewHide'), 
self.operationOnTop)/

My plugin doesn't crash during loading, but nothing happens when I close 
the composer.
I've added « print 'operationOnTop' » to the end of the function, to 
test its loading. Apparently, the signal is not catched, as I have no 
return in the Python pannel.

Can you see what I've missed in each case ?

Any help would be greatly appreciated.
Kind regards


PS : I've tried to make the connection in the class constructor :

/class OperationDialog(QtGui.QDialog): //
//def __init__(self, iface): //
//QtGui.QDialog.__init__(self) //
//self.ui = Ui_operation() //
//self.ui.setupUi(self) //
//self.iface = iface //
//self.canvas = self.iface.mapCanvas()//
//...//
//QgsComposerView.composerViewHide.connect(self.operationOnTop)//
///
Should I put it in the function which creates the composer?



-- 

-- 

---------------------------

Vincent Damoy - Responsable SIG
Conservatoire d'Espaces Naturels du Nord et du Pas-de-Calais
152 bd de Paris - 62190 Lillers
Tél : 03.21.54.75.00 - Fax : 03.21.54.56.07
/*Pour adhérer au Conservatoire :* 
www.cen-npdc.org/nous-rejoindre/adherent.html/ 	



	/Pour le respect de l'environnement, n'imprimez ce message qu'en cas de 
nécessité !/ 	


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131216/92312ee2/attachment.html>


More information about the Qgis-developer mailing list