[Kde-bindings] Help start with MonoDevelop and Qyoto GUI

Arno Rehn arno at arnorehn.de
Mon Feb 8 13:58:35 UTC 2010


On Monday 08 February 2010 14:51:23 you wrote:
> The signals are already defined in gui.cs:
> 
> ...
>     RetranslateUi(Dialog);
>     QObject.Connect(buttonBox, Qt.SIGNAL("accepted()"), Dialog,
> Qt.SLOT("accept()")); QObject.Connect(buttonBox, Qt.SIGNAL("rejected()"),
> Dialog, Qt.SLOT("reject()"));
> 
> 
> Here's my main.cs:
> 
> **********************
> using System;
> using Qyoto;
> 
> namespace test {
> 
> 	class MainClass
> 	{
> 		public static int Main(String[] args) {
> 	        new QApplication(args);
> 			MainApp mainwindow = new MainApp();
> 			mainwindow.Show();
> 	        return QApplication.Exec();
> 		}
> 
> 	}
> }
> **********************
> 
> and here's my MainWindow.cs:
> 
> **********************
> using System;
> using Qyoto;
> 
> namespace test {
> 
> 	public class MainApp : QDialog{
> 
> 		Ui_Dialog ui = new Ui_Dialog();
> 
> 		public MainApp() {
> 			ui.SetupUi(this);
> 			Connect(ui.buttonBox, SIGNAL("clicked()"), delegate {
> 				ui.label.Text = "Init App";
> 				QMessageBox.About(this, "About Dialog", "Button 
clicked!");
> 			});
> 			Connect(ui.buttonBox, SIGNAL("rejected()"), qApp, 
SLOT("quit()"));
> 		}
> 	}
> }
> **********************
Yes, of course. It was just example code that I wrote, to show you how to do 
integrate the generated code. Read up on what the reject() and accept() slots 
for QDialog do (see the Qt documentation). Either of them will close the 
dialog, but QDialog.Exec() will return a different value, depending on what 
slot is called. As the dialog is your only window of the app, the app will 
simply exit. Create a seperate button in your UI and connect the clicked() 
signal to a delegate. In that delegate you can then put the code to show your 
message box.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list