[PyKDE] [solved] Poss OT calling widget ?

Andreas Pakulat apaku at gmx.de
Mon Sep 11 08:42:19 BST 2006


On 10.09.06 21:41:28, Dave S wrote:
> I SOLVED it !!!!!!!! :)
> 
> OK it took me 8 straight hours of hitting head on keyboard but ...
> 
> def main(args):
> 
>     app = QApplication(args)
>     docview = View()
>     docview.parent = docview
>     app.setMainWidget(docview)
>     docview.show()
>     QObject.connect(app, SIGNAL('lastWindowClosed()'),app, SLOT('quit()'))
>     app.exec_loop()
>     
> if __name__=="__main__":
>     main(sys.argv)
> 
> 
> so I have self.parent ....
> 
>         view = dialogs.form1.Form1(self.parent, '', QWidget.WType_Dialog)
>         view.show()
> 
> And it works :)

I don't get it.

Anyway such things are normally done with a dialog. For example if the
first dialog (form1) should popup when a button in your mainwindow is
pressed, you connect a slot to the clicked() signal of that button.
Inside that slot you do

f1 = form1(self)
if f1.exec() == QDialog.Accepted:
  f2 = form2(self)
    if f2.exec() == QDialog.Accepted:
      use the values put into either form

exec() runs the forms as modal ones, so you can't access the mainwindow
after the form is shown. When the user clicks the "Ok" button (or
whatever you connected to the QDialog.accept slot) the dialog is closed
and the 2nd dialog is popping up. 

If you need modeless dialogs it get's a bit complicated, you'd create
and show() the first dialog and then you'd connect it's accept signal to
a slot of the mainwindow. In that slot you show() the 2nd dialog and
have it's accept signal connected to another slot in your mainwindow.
There you can then get all the values from the forms.

Andreas

-- 
You will stop at nothing to reach your objective, but only because your
brakes are defective.




More information about the PyQt mailing list