summaryrefslogtreecommitdiffstats
path: root/qtsharp/src/examples/tutorials
diff options
context:
space:
mode:
Diffstat (limited to 'qtsharp/src/examples/tutorials')
-rw-r--r--qtsharp/src/examples/tutorials/Makefile.am24
-rw-r--r--qtsharp/src/examples/tutorials/README14
-rw-r--r--qtsharp/src/examples/tutorials/t1.cs23
-rw-r--r--qtsharp/src/examples/tutorials/t2.cs28
-rw-r--r--qtsharp/src/examples/tutorials/t3.cs29
-rw-r--r--qtsharp/src/examples/tutorials/t4.cs44
-rw-r--r--qtsharp/src/examples/tutorials/t5.cs45
-rw-r--r--qtsharp/src/examples/tutorials/t6.cs58
-rw-r--r--qtsharp/src/examples/tutorials/t7.cs78
-rw-r--r--qtsharp/src/examples/tutorials/tutorials.build75
10 files changed, 418 insertions, 0 deletions
diff --git a/qtsharp/src/examples/tutorials/Makefile.am b/qtsharp/src/examples/tutorials/Makefile.am
new file mode 100644
index 00000000..52d1adce
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/Makefile.am
@@ -0,0 +1,24 @@
+all:
+ csant -D$(CSC_NAME)=$(CSC) -C $(CSC_NAME)
+ chmod 0755 *.exe
+
+clean:
+ rm -rf *.exe
+
+distclean: clean
+
+install:
+ mkdir -p $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials
+ cat t1.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t1.cs.gz
+ cat t2.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t2.cs.gz
+ cat t3.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t3.cs.gz
+ cat t4.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t4.cs.gz
+ cat t5.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t5.cs.gz
+ cat t6.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t6.cs.gz
+ cat t7.cs | gzip -9c > $(DESTDIR)$(datadir)/doc/qtcsharp/tutorials/t7.cs.gz
+
+uninstall:
+ rm -rf $(datadir)/doc/qtcsharp/tutorials/*.cs.gz
+ rm -rf $(datadir)/doc/qtcsharp/tutorials/*.cs
+
+.PHONY: all clean distclean install
diff --git a/qtsharp/src/examples/tutorials/README b/qtsharp/src/examples/tutorials/README
new file mode 100644
index 00000000..21e302ea
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/README
@@ -0,0 +1,14 @@
+These tutorials are translations of the C++ versions provided with
+Qt 3.0.x. Tutorial 7 is included, but it does not yet work properly
+because it is not yet possible to create custom signals.
+
+Assuming that you're using Mono and that Qt.dll has been
+installed in /opt/kde/lib you can compile the first tutorial
+using
+
+> mcs -L /opt/kde/lib -r Qt t1.cs
+
+To run the first tutorial, use
+
+> mono t1.exe
+
diff --git a/qtsharp/src/examples/tutorials/t1.cs b/qtsharp/src/examples/tutorials/t1.cs
new file mode 100644
index 00000000..3dc075b1
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t1.cs
@@ -0,0 +1,23 @@
+// Qt# tutorial 1
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ QPushButton hello = new QPushButton ("Hello world!", null);
+ // In C++, the second parameter is 0 (null pointer)
+
+ hello.Resize (100, 30);
+
+ a.SetMainWidget (hello);
+ hello.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t2.cs b/qtsharp/src/examples/tutorials/t2.cs
new file mode 100644
index 00000000..44eb304b
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t2.cs
@@ -0,0 +1,28 @@
+// Qt# tutorial 2
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ QPushButton quit = new QPushButton ("Quit", null);
+ // In C++, the second parameter is 0 (null pointer)
+
+ quit.Resize (75, 30);
+ quit.SetFont (new QFont ("Times", 18, QFont.Weight.Bold));
+ // In C++, QFont::Bold is sufficient
+
+ QObject.Connect ( quit, QtSupport.SIGNAL ("clicked()"), a, QtSupport.SLOT ("Quit()") );
+ // SIGNAL and SLOT are static functions of QtSupport
+
+ a.SetMainWidget (quit);
+ quit.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t3.cs b/qtsharp/src/examples/tutorials/t3.cs
new file mode 100644
index 00000000..a1c76ce4
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t3.cs
@@ -0,0 +1,29 @@
+// Qt# tutorial 3
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ QVBox box = new QVBox ();
+ box.Resize (200, 120);
+
+ QPushButton quit = new QPushButton ("Quit", box);
+ quit.SetFont (new QFont ("Times", 18, QFont.Weight.Bold));
+ // In C++, QFont::Bold is sufficient
+
+ QObject.Connect ( quit, QtSupport.SIGNAL ("clicked()"), a, QtSupport.SLOT ("Quit()") );
+ // SIGNAL and SLOT are static functions of QtSupport
+
+ a.SetMainWidget (box);
+ box.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t4.cs b/qtsharp/src/examples/tutorials/t4.cs
new file mode 100644
index 00000000..5373af19
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t4.cs
@@ -0,0 +1,44 @@
+// Qt# tutorial 4
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+public class MyWidget : QWidget {
+
+ public MyWidget (QWidget parent, String name) : base (parent, name)
+ // In C++, parent and name have default values of 0 (null pointer)
+ {
+ this.SetMinimumSize (200, 120);
+ this.SetMaximumSize (200, 120);
+
+ QPushButton quit = new QPushButton ("Quit", this, "quit");
+ quit.SetGeometry (62, 40, 75, 30);
+ quit.SetFont (new QFont ("Times", 18, QFont.Weight.Bold) );
+
+ Connect ( quit, SIGNAL ("clicked()"), qApp, SLOT ("Quit()") );
+ // In C++, qApp is a global variable. Here it's a property of the QObject
+ // class, which we inherit, giving the same effect. We also inherit the
+ // static method connect().
+ }
+
+ public MyWidget (QWidget parent) : this (parent, "") {}
+ public MyWidget () : this (null, "") {}
+ // Note that it was necessary to use an empty string ("")
+ // in the above. Using null does not work at runtime.
+}
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ MyWidget w = new MyWidget ();
+ w.SetGeometry (100, 100, 200, 120);
+ a.SetMainWidget (w);
+ w.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t5.cs b/qtsharp/src/examples/tutorials/t5.cs
new file mode 100644
index 00000000..4feadae5
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t5.cs
@@ -0,0 +1,45 @@
+// Qt# tutorial 5
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+public class MyWidget : QVBox {
+
+ public MyWidget (QWidget parent, String name) : base (parent, name)
+ // In C++, parent and name have default values of 0 (null pointer)
+ {
+ QPushButton quit = new QPushButton ("Quit", this, "quit");
+ quit.SetFont ( new QFont ("Times", 18, QFont.Weight.Bold) );
+
+ QObject.Connect ( quit, SIGNAL ("clicked()"), qApp, SLOT ("Quit()") );
+
+ QLCDNumber lcd = new QLCDNumber (2, this, "lcd" );
+
+ QSlider slider = new QSlider (Orientation.Horizontal, this, "slider");
+ // Note that Orientation is defined in the Qt class
+ slider.SetRange (0, 99);
+ slider.SetValue (0);
+
+ Connect ( slider, SIGNAL ("valueChanged(int)"), lcd, SLOT ("Display(int)") );
+ }
+
+ public MyWidget (QWidget parent) : this (parent, "") {}
+ public MyWidget () : this (null, "") {}
+ // Note that it was necessary to use an empty string ("")
+ // in the above. Using null does not work at runtime.
+}
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ MyWidget w = new MyWidget ();
+ a.SetMainWidget (w);
+ w.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t6.cs b/qtsharp/src/examples/tutorials/t6.cs
new file mode 100644
index 00000000..223e0ff1
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t6.cs
@@ -0,0 +1,58 @@
+// Qt# tutorial 6
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+
+using System;
+using Qt;
+
+public class LCDRange : QVBox {
+
+ public LCDRange (QWidget parent, String name) : base (parent, name)
+ // In C++, parent and name have default values of 0 (null pointer)
+ {
+ QLCDNumber lcd = new QLCDNumber (2, this, "lcd" );
+ QSlider slider = new QSlider (Orientation.Horizontal, this, "slider");
+ slider.SetRange (0, 99);
+ slider.SetValue (0);
+
+ Connect ( slider, SIGNAL ("valueChanged(int)"), lcd, SLOT ("Display(int)") );
+ }
+
+ public LCDRange (QWidget parent) : this (parent, "") {}
+ public LCDRange () : this (null, "") {}
+ // Note that it was necessary to use an empty string ("")
+ // in the above. Using null does not work at runtime.
+}
+
+public class MyWidget : QVBox {
+
+ MyWidget (QWidget parent, String name) : base (parent, name)
+ {
+ QPushButton quit = new QPushButton ("Quit", this, "quit");
+ quit.SetFont ( new QFont ("Times", 18, QFont.Weight.Bold) );
+
+ Connect ( quit, SIGNAL ("clicked()"), qApp, SLOT ("Quit()") );
+
+ QGrid grid = new QGrid (4, this);
+
+ for ( int c =0; c < 4; c++ )
+ for ( int r = 0; r < 4; r++ )
+ new LCDRange (grid);
+ }
+
+ public MyWidget (QWidget parent) : this (parent, "") {}
+ public MyWidget () : this (null, "") {}
+}
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ MyWidget w = new MyWidget ();
+ a.SetMainWidget (w);
+ w.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/t7.cs b/qtsharp/src/examples/tutorials/t7.cs
new file mode 100644
index 00000000..de9011f2
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/t7.cs
@@ -0,0 +1,78 @@
+// Qt# tutorial 7
+// Based on the Qt tutorial
+// Implemented by Marcus Urban
+//
+// This example currently does not funtion properly because custom
+// signals are not yet implemented.
+
+using System;
+using Qt;
+
+[DeclareQtSignal ("valueChanged(int)")]
+public class LCDRange : QVBox {
+
+ QSlider slider;
+
+ public LCDRange (QWidget parent, String name) : base (parent, name)
+ // In C++, parent and name have default values of 0 (null pointer)
+ {
+ QLCDNumber lcd = new QLCDNumber (2, this, "lcd" );
+ slider = new QSlider (Orientation.Horizontal, this, "slider");
+ slider.SetRange (0, 99);
+ slider.SetValue (0);
+
+ Connect ( slider, SIGNAL ("valueChanged(int)"), lcd, SLOT ("Display(int)") );
+ Connect ( slider, SIGNAL ("valueChanged(int)"), SIGNAL ("valueChanged(int)"));
+ }
+
+ public LCDRange (QWidget parent) : this (parent, "") {}
+ public LCDRange () : this (null, "") {}
+ // Note that it was necessary to use an empty string ("")
+ // in the above. Using null does not work at runtime.
+
+ public void SetValue (int value)
+ {
+ slider.SetValue (value);
+ }
+}
+
+public class MyWidget : QVBox {
+
+ MyWidget (QWidget parent, String name) : base (parent, name)
+ {
+ QPushButton quit = new QPushButton ("Quit", this, "quit");
+ quit.SetFont ( new QFont ("Times", 18, QFont.Weight.Bold) );
+
+ Connect ( quit, SIGNAL ("clicked()"), qApp, SLOT ("Quit()") );
+
+ QGrid grid = new QGrid (4, this);
+
+ LCDRange previous = null;
+
+ for ( int c =0; c < 4; c++ ) {
+ for ( int r = 0; r < 4; r++ ) {
+ LCDRange lr = new LCDRange (grid);
+ if (previous != null)
+ Connect (lr, SIGNAL ("valueChanged(int)"),
+ previous, SLOT ("SetValue(int)") );
+ previous = lr;
+ }
+ }
+ }
+
+ public MyWidget (QWidget parent) : this (parent, "") {}
+ public MyWidget () : this (null, "") {}
+}
+
+public class Example {
+
+ public static int Main (String[] args)
+ {
+ QApplication a = new QApplication (args);
+
+ MyWidget w = new MyWidget ();
+ a.SetMainWidget (w);
+ w.Show ();
+ return a.Exec ();
+ }
+}
diff --git a/qtsharp/src/examples/tutorials/tutorials.build b/qtsharp/src/examples/tutorials/tutorials.build
new file mode 100644
index 00000000..f3b211f2
--- /dev/null
+++ b/qtsharp/src/examples/tutorials/tutorials.build
@@ -0,0 +1,75 @@
+<?xml version="1.0">
+<project name="Qt# Samples" default="all">
+ <target name="all">
+ <compile output="t1.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t1.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t2.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t2.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t3.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t3.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t4.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t4.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t5.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t5.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t6.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t6.cs" />
+ </sources>
+ </compile>
+
+ <compile output="t7.exe" target="exe" optimize="true">
+ <references>
+ <file name="../../bindings/Qt.dll" />
+ </references>
+
+ <sources>
+ <file name="t7.cs" />
+ </sources>
+ </compile>
+
+ </target>
+</project>