[Kde-bindings] Qt, Qyoto buttons work intermediately

Linuxoid Oz linuxoidoz at yahoo.com.au
Tue Feb 16 21:52:56 UTC 2010


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 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 MainWindow. This is my slot:

QObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), mainwin, 
Qt.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 to the MainWindow. If I use a slot in MainWindow I pass the slot 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 :QWidget I should then pass the reference to itself as 'this' rather than a reference to the MainWindow?

In the StartWindow the QMessageBox also needs a parent reference, that's why 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 need to pass a reference to the parent window? If I pass anything else it complains that that reference doesn't exist in the current context.


Yes. You didn't understand how signals and slots work. This explains it all: 
http://doc.trolltech.com/4.6/signalsandslots.html .

Short summery: This line
QObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), mainwin, 
Qt.SLOT("ShowAbout(mainwin, page)"));
connects to a method (slot) ShowAbout() which 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 
expected to be types, not variables. But there is no type called 'mainwin' and 
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 connections. (QObject.Connect(sender, SIGNAL(/*signal*/), 
delegate { /* ... */ });)



      __________________________________________________________________________________
Yahoo!7: Catch-up on your favourite Channel 7 TV shows easily, legally, and for free at PLUS7. www.tv.yahoo.com.au/plus7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100216/64decb27/attachment.html>


More information about the Kde-bindings mailing list