[PyQt] Call a window from other parent window

Mark Summerfield mark at qtrac.eu
Wed Oct 17 07:47:50 BST 2007


On 2007-10-16, Sergio Jovani Guzmán wrote:
> Hi all!
>
> I am learning PyQt and I have a question.
>
> I have two classes, one for each widget:
>
> ==================
> class Main(QMainWindow):
> 	def __init__(self):
> 		QMainWindow.__init__(self)
> 		loadUi("frmmain.ui", self)
>
> class Conectar(QDialog):
>
> 	def __init__(self):
> 		QDialog.__init__(self)
> 		loadUi("frmconectar.ui", self)
> =====================
>
> My question is, how can I call and show a widget from other with parent?
>
> For example, open Conectar() window from Main() window?
>
> Many thanks!

You need a method in your Main() class, something like this (untested):

    def runConectar(self):
	conectar = Conectar(self)
	if conectar.exec():
	    pass # User clicked OK

And in the Main() __init__ method, assuming you have an action called
runConectarAction:

    self.connect(runConectarAction, SIGNAL("triggered()"),
		 self.runConectar)



-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu




More information about the PyQt mailing list