[PyKDE] [solved] Poss OT calling widget ?
Dave S
eric3 at pusspaws.net
Mon Sep 11 21:14:30 BST 2006
On Monday 11 September 2006 08:42, Andreas Pakulat wrote:
> 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.
This is just the way I managed to get things to work - makes a kind of sense
but I am open to suggestions
>
> 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
Ah I see this is very usefull. It also answers a question I was about to post
on :)
>
> 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.
OK
>
> 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.
modal is good !
>
> Andreas
Thanks again,
Dave
More information about the PyQt
mailing list