[Kde-bindings] Qt, Qyoto buttons work intermediately

linuxoidoz at yahoo.com.au linuxoidoz at yahoo.com.au
Thu Feb 18 09:44:20 UTC 2010

So if I understand it right, if I have one class MainWindow with a button btn1, and another class StartWindow with a button btn2, then you use this

Connect(button, SIGNAL("clicked()"), otherObject.btn2, SLOT("buttonClicked()"));

to emit a signal buttonClicked() from btn2 in StartWindow when button btn1 in MainWindow has been clicked? 

>you tell the meta object system to invoke "otherObject.buttonClicked()" when the signal "clicked()" in the object "button" is emitted

In C# you declare a method first as
this.btn1.Clicked += new System.EventHandler(this.OnBtn1Clicked);

and then implement it as
protected virtual void OnBtn1Clicked (object sender, System.EventArgs e)

How do you do this with Qt in C#? Sorry, I just can't understand this signal/slot thing without comparable examples. All I need to know is, for example, how to show a message box from another class and pass a variable to it.

		QObject.Connect(btnAbout, Qt.SIGNAL("clicked()"), this, Qt.SLOT("ShowAbout(variable)"));

		private void ShowAbout() {
			QMessageBox.About(this, "About", variable.ToString());

simply doesn't work. How can you pass a reference to a widget in the SLOT if you're saying you need to pass a type, NOT a variable, when the variable is invisible to the QMessageBox unless you pass it to the method.

If you could send me a link to signal/slot C# examples, I'm happy to read, but this Qt-C# signal/slot theory is too different to plain C# to comprehend.

More information about the Kde-bindings mailing list