--===============1990425924== Content-Type: multipart/alternative; boundary="0-1030954344-1266357176=:50140" --0-1030954344-1266357176=:50140 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable I've read that thing about the signals/slots and that was exactly what I wa= s trying to do (at least I thought that was exactly what they said). Here's= an example from a Qt Address Book tutorial: connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); As the QMessageBox needs a parent reference, 'this' is fine for the MainWin= dow. This is my slot: QObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), mainwin, =0AQt.SLOT("Show= About(mainwin, page)")); First, the Qt one doesn't have these " ", so I thought it might be a Qyoto = thing. 'this' is a reference to MainWindow. In my StartWindow, 'mainwin' is= a reference to the MainWindow. If I use a slot in MainWindow I pass the sl= ot a 'this' reference as in the example. If I use a slot in the StartWindow= I pass it a reference to MainWindow as 'mainwin'. Are you saying if I declare the SecondWindow class as inherited from :QWidg= et I should then pass the reference to itself as 'this' rather than a refer= ence to the MainWindow? In the StartWindow the QMessageBox also needs a parent reference, that's wh= y I pass 'mainwin'=A0 - reference to parent MainWindow. What do you mean by= passing a type rather than a variable? How do you pass a type if you need = to pass a reference to the parent window? If I pass anything else it compla= ins that that reference doesn't exist in the current context. =0A Yes. You didn't understand how signals and slots work. This explains it all= :=20 http://doc.trolltech.com/4.6/signalsandslots.html . Short summery: This line QObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), mainwin,=20 Qt.SLOT("ShowAbout(mainwin, page)")); connects to a method (slot) ShowAbout() which takes two arguments: one of t= ype=20 mainwin, one of type page. There are two reasons why this won't work: 1. The signal doesn't provide any parameters, but the slot does. How is thi= s=20 supposed to work? 2. You give a method signature to the SLOT method, i.e. mainwin and page ar= e=20 expected to be types, not variables. But there is no type called 'mainwin' = and=20 there is also no type called 'page'. Both are variables. But this is not ho= w=20 signals and slots work. SIGNAL and SLOT expect _signatures_, not method cal= l=20 expressions. Furthermore, you can only define slots in QObject subclasses. Otherwise you= =20 have to use delegate connections. (QObject.Connect(sender, SIGNAL(/*signal*= /),=20 delegate { /* ... */ });) =0A=0A=0A ____________________________________________________________= ______________________=0AYahoo!7: Catch-up on your favourite Channel 7 TV s= hows easily, legally, and for free at PLUS7. www.tv.yahoo.com.au/plus7 --0-1030954344-1266357176=:50140 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
I've read that thing about the signals/slots = and that was exactly what I was trying to do (at least I thought that was e= xactly what they said). Here's an example from a Qt Address Book tutorial:<= br>
connect(nextButton, SIGNAL(clicked()), this, SLOT(next()));

= As the QMessageBox needs a parent reference, 'this' is fine for the MainWin= dow. This is my slot:

QObject.Connect(btnAbout, Qt.SIGNAL("clicked()= "), mainwin, =0AQt.SLOT("ShowAbout(mainwin, page)"));

First, the Qt = one doesn't have these " ", so I thought it might be a Qyoto thing. 'this' = is a reference to MainWindow. In my StartWindow, 'mainwin' is a reference t= o the MainWindow. If I use a slot in MainWindow I pass the slot a 'this' re= ference as in the example. If I use a slot in the StartWindow I pass it a r= eference to MainWindow as 'mainwin'.

Are you saying if I declare the= SecondWindow class as inherited from :QWidget I should then pass the refer= ence to itself as 'this' rather than a reference to the MainWindow?

= In the StartWindow the QMessageBox also needs a parent reference, that's wh= y I pass 'mainwin'  - reference to parent MainWindow. What do you mean= by passing a type rather than a variable? How do you pass a type if you ne= ed to pass a reference to the parent window? If I pass anything else it com= plains that that reference doesn't exist in the current context.
=0A
=
Yes. You didn't understan= d how signals and slots work. This explains it all:
http://doc.tro= lltech.com/4.6/signalsandslots.html .

Short summery: This lineQObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), mainwin,
Qt.SLOT("S= howAbout(mainwin, page)"));
connects to a method (slot) ShowAbout() whic= h takes two arguments: one of type
mainwin, one of type page. There are= two reasons why this won't work:

1. The signal doesn't provide any = parameters, but the slot does. How is this
supposed to work?
2. You = give a method signature to the SLOT method, i.e. mainwin and page are
e= xpected to be types, not variables. But there is no type called 'mainwin' a= nd
there is also no type called 'page'. Both are variables. But this is not how
signals and slots work. SIGNAL and SLOT expect _signatures_= , not method call
expressions.

Furthermore, you can only define = slots in QObject subclasses. Otherwise you
have to use delegate connect= ions. (QObject.Connect(sender, SIGNAL(/*signal*/),
delegate { /* ... */= });)

=0A=0A=0A=0A   --0-1030954344-1266357176=:50140-- --===============1990425924== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kde-bindings mailing list Kde-bindings@kde.org https://mail.kde.org/mailman/listinfo/kde-bindings --===============1990425924==--