[Kde-bindings] playground/bindings/kimono/examples/tutorial

Richard Dale Richard_Dale at tipitina.demon.co.uk
Thu Jan 25 09:32:08 UTC 2007


SVN commit 626972 by rdale:

* Convert some examples to Qt 4.x and make them compile

CCMAIL: kde-bindings at kde.org



 M  +1 -2      t1/t1.cs  
 M  +3 -8      t2/t2.cs  
 M  +10 -13    t3/t3.cs  
 M  +8 -11     t4/t4.cs  
 M  +21 -16    t5/t5.cs  
 M  +33 -20    t6/t6.cs  


--- trunk/playground/bindings/kimono/examples/tutorial/t1/t1.cs #626971:626972
@@ -1,11 +1,10 @@
 using System;
-using System.Runtime.InteropServices;
 using Qyoto;
 
 public class T1 
 {
 	public static int Main(String[] args) {
-		QApplication a = new QApplication(args);
+		new QApplication(args);
 		
 		QPushButton hello = new QPushButton("Hello world!", null);
 		hello.Resize(100, 30);
--- trunk/playground/bindings/kimono/examples/tutorial/t2/t2.cs #626971:626972
@@ -1,7 +1,5 @@
 using System;
-using System.Runtime.InteropServices;
-using Qt;
-namespace Qt {
+using Qyoto;
 
 public class T2 : Qt
 {
@@ -10,14 +8,11 @@
 		
 		QPushButton quit = new QPushButton( "Quit", null );
 		quit.Resize( 75, 30 );
-		quit.SetFont( new QFont( "Times", 18, (int) QFont.Weight.Bold ) );
+		quit.Font = new QFont( "Times", 18, (int) QFont.Weight.Bold );
 
 		QObject.Connect( quit, SIGNAL("clicked()"), a, SLOT("quit()") );
 		
-		a.SetMainWidget(quit);
 		quit.Show();
-		return a.Exec();
+		return QApplication.Exec();
 	}
 }
-
-}
--- trunk/playground/bindings/kimono/examples/tutorial/t3/t3.cs #626971:626972
@@ -1,25 +1,22 @@
 using System;
-using System.Runtime.InteropServices;
-using Qt;
-namespace Qt {
+using Qyoto;
 
 public class T3 : Qt
 {
 	public static int Main(String[] args) {
-		QApplication a = new QApplication(args);
+		QApplication app = new QApplication(args);
 		
-		QVBox box = new QVBox();
-		box.Resize( 200, 120 );
+		QWidget window = new QWidget();
+		window.Resize(200, 120);
 
-		QPushButton quit = new QPushButton( "Quit", box );
-		quit.SetFont( new QFont( "Times", 18, (int) QFont.Weight.Bold ) );
+		QPushButton quit = new QPushButton( "Quit", window );
+		quit.Font = new QFont( "Times", 18, (int) QFont.Weight.Bold );
+		quit.SetGeometry(10, 40, 180, 40);
 
-		QObject.Connect( quit, SIGNAL("clicked()"), a, SLOT("quit()") );
+		QObject.Connect( quit, SIGNAL("clicked()"), app, SLOT("quit()") );
 		
-		a.SetMainWidget(box);
-		box.Show();
-		return a.Exec();
+		window.Show();
+		return QApplication.Exec();
 	}
 }
 
-}
--- trunk/playground/bindings/kimono/examples/tutorial/t4/t4.cs #626971:626972
@@ -1,29 +1,26 @@
 using System;
-using System.Runtime.InteropServices;
-using Qt;
+using Qyoto;
 
 public class MyWidget : QWidget
 {
-	public MyWidget() : this(null, null) {}
+	public MyWidget() : this(null) {}
 
-	public MyWidget(QWidget parent, string name) : base(parent, name) {
-		SetMinimumSize( 200, 120 );
-		SetMaximumSize( 200, 120 );
+	public MyWidget(QWidget parent) : base(parent) {
+		SetFixedSize(200, 120);
 
-		QPushButton quit = new QPushButton( "Quit", this, "quit" );
+		QPushButton quit = new QPushButton( Tr("Quit"), this );
 		quit.SetGeometry( 62, 40, 75, 30 );
-		quit.SetFont( new QFont( "Times", 18, (int) QFont.Weight.Bold ) );
+		quit.Font = new QFont( "Times", 18, (int) QFont.Weight.Bold );
 
 		Connect( quit, SIGNAL("clicked()"), qApp, SLOT("quit()") );
 	}
 
 	public static int Main(String[] args) {
-		QApplication a = new QApplication(args);
+		new QApplication(args);
 
 		MyWidget w = new MyWidget();
 		w.SetGeometry( 100, 100, 200, 120 );
-		a.SetMainWidget( w );
 		w.Show();
-		return a.Exec();
+		return QApplication.Exec();
 	}
 }
--- trunk/playground/bindings/kimono/examples/tutorial/t5/t5.cs #626971:626972
@@ -1,32 +1,37 @@
 using System;
-using System.Runtime.InteropServices;
-using Qt;
+using Qyoto;
 
-public class MyWidget : QVBox
+public class MyWidget : QWidget
 {
-	public MyWidget() : this(null, null) {}
+	public MyWidget() : this(null) {}
 
-	public MyWidget(QWidget parent, string name) : base(parent, name) {
-		QPushButton quit = new QPushButton( "Quit", this, "quit" );
-		quit.SetFont( new QFont( "Times", 18, (int) QFont.Weight.Bold ) );
+	public MyWidget(QWidget parent) : base(parent) {
+		QPushButton quit = new QPushButton(Tr("Quit"));
+		quit.Font = new QFont("Times", 18, (int) QFont.Weight.Bold);
 
-		Connect( quit, SIGNAL("clicked()"), qApp, SLOT("quit()") );
+		QLCDNumber lcd = new QLCDNumber(2);
+		lcd.segmentStyle = QLCDNumber.SegmentStyle.Filled;
 
-		QLCDNumber lcd  = new QLCDNumber( 2, this, "lcd" );
+		QSlider slider = new QSlider(Qt.Orientation.Horizontal);
+		slider.SetRange(0, 99);
+		slider.Value = 0;
 
-		QSlider slider = new QSlider( Orientation.Horizontal, this, "slider" );
-		slider.SetRange( 0, 99 );
-		slider.SetValue( 0 );
+		Connect(quit, SIGNAL("clicked()"), qApp, SLOT("quit()"));
+		Connect(slider, SIGNAL("valueChanged(int)"),
+            lcd, SLOT("display(int)"));
 
-		Connect( slider, SIGNAL("valueChanged(int)"), lcd, SLOT("display(int)") );
+		QVBoxLayout layout = new QVBoxLayout();
+		layout.AddWidget(quit);
+		layout.AddWidget(lcd);
+		layout.AddWidget(slider);
+		SetLayout(layout);
 	}
 
 	public static int Main(String[] args) {
-		QApplication a = new QApplication(args);
+		new QApplication(args);
 
 		MyWidget w = new MyWidget();
-		a.SetMainWidget( w );
 		w.Show();
-		return a.Exec();
+		return QApplication.Exec();
 	}
 }
--- trunk/playground/bindings/kimono/examples/tutorial/t6/t6.cs #626971:626972
@@ -1,43 +1,56 @@
 using System;
-using System.Runtime.InteropServices;
-using Qt;
+using Qyoto;
 
-public class LCDRange : QVBox
+public class LCDRange : QWidget
 {
-	public LCDRange(QWidget parent) : this(parent, null) {}
+	public LCDRange() : this(null) {}
 
-	public LCDRange(QWidget parent, string name) : base(parent, name) {
-		QLCDNumber lcd  = new QLCDNumber( 2, this, "lcd" );
-		QSlider slider = new QSlider( Orientation.Horizontal, this, "slider" );
+	public LCDRange(QWidget parent) : base(parent) {
+		QLCDNumber lcd  = new QLCDNumber( 2, this );
+		lcd.segmentStyle = QLCDNumber.SegmentStyle.Filled;
+
+		QSlider slider = new QSlider( Orientation.Horizontal, this );
 		slider.SetRange( 0, 99 );
-		slider.SetValue( 0 );
+		slider.Value = 0;
 		Connect( slider, SIGNAL("valueChanged(int)"), lcd, SLOT("display(int)") );
+
+		QVBoxLayout layout = new QVBoxLayout();
+		layout.AddWidget(lcd);
+		layout.AddWidget(slider);
+		SetLayout(layout);
 	}
 }
 
-public class MyWidget : QVBox
+public class MyWidget : QWidget
 {
-	public MyWidget() : this(null, null) {}
+	public MyWidget() : this(null) {}
 
-	public MyWidget(QWidget parent, string name) : base(parent, name) {
-		QPushButton quit = new QPushButton( "Quit", this, "quit" );
-		quit.SetFont( new QFont( "Times", 18, (int) QFont.Weight.Bold ) );
+	public MyWidget(QWidget parent) : base(parent) {
+		QPushButton quit = new QPushButton( "Quit", this );
+		quit.Font = new QFont( "Times", 18, (int) QFont.Weight.Bold );
 
 		Connect( quit, SIGNAL("clicked()"), qApp, SLOT("quit()") );
 
-		QGrid grid = new QGrid( 4, this );
+		QGridLayout grid = new QGridLayout();
 
-		for ( int r = 0; r < 4; r++ )
-			for ( int c =0; c < 4; c++ )
-				new LCDRange(grid);
+		for ( int row = 0; row < 3; row++ ) {
+			for ( int column = 0; column < 3; column++ ) {
+				LCDRange lcdRange = new LCDRange();
+				grid.AddWidget(lcdRange, row, column);
+			}
+		}
+
+		QVBoxLayout layout = new QVBoxLayout();
+		layout.AddWidget(quit);
+		layout.AddLayout(grid);
+		SetLayout(layout);
 	}
 
 	public static int Main(String[] args) {
-		QApplication a = new QApplication(args);
+		new QApplication(args);
 
 		MyWidget w = new MyWidget();
-		a.SetMainWidget( w );
 		w.Show();
-		return a.Exec();
+		return QApplication.Exec();
 	}
 }



More information about the Kde-bindings mailing list