comparison mini/test1/main.d @ 257:17b5e13364b7 lifetime

(none)
author maxter
date Wed, 16 Sep 2009 13:56:02 +0000
parents 7dd099050621
children
comparison
equal deleted inserted replaced
256:b1abe7f57321 257:17b5e13364b7
1 module main;
2
3 /+
4 import qt.gui.QApplication;
1 import qt.core.QCoreApplication; 5 import qt.core.QCoreApplication;
6 import qt.gui.QDialogButtonBox;
7 +/
8 import tango.io.Stdout;
2 9
3 version(Tango) {} else { import std.stdio; } 10 extern(C) void* qtd_test_Object();
11 extern(C) void qtd_test_delete_Object(void* obj);
4 12
5 int main(string[] args) 13 import qt.core.QObject;
14 import qt.core.QCryptographicHash;
15 import qt.core.QFSFileEngine;
16 import qt.QtdObject;
17
18
19 void main()
6 { 20 {
7 auto app = new QCoreApplication(args); 21 //auto nativeId = qtd_test_Object();
22 scope obj = new QCryptographicHash(QCryptographicHash_Algorithm.Md5);
23 obj.__nativeOwnership = true;
24 qtd_test_delete_Object(obj.__nativeId);
25 //Stdout(obj).newline;
26 }
27
28 /+
29 void main(char[][] args)
30 {
31 /+
32 scope app = new QCoreApplication(args);
33 app.aboutToQuit.connect(&quit);
34 Stdout(app.children[0]).newline;
35 +/
8 36
9 auto parent = new QObject(); 37 /+
10 parent.setObjectName("papa"); 38 scope parent = new QObject;
11 auto child1 = new QObject(parent); 39 qtd_qobject(parent.__nativeId);
12 child1.setObjectName("child1"); 40 Stdout(parent.children[0]).newline;
13 auto child2 = new QObject(parent); 41 +/
14 child2.setObjectName("child2");
15 auto child3 = new QObject(parent);
16 child3.setObjectName("child3");
17 42
18 auto cd = parent.children;
19 43
20 writeln(app.arguments);
21 foreach(child; cd)
22 writeln(child.objectName);
23 44
24 app.setLibraryPaths(["freakin", "bloody", "awesome!"]); 45
46 //return app.exec();
47 }
25 48
26 writeln(app.libraryPaths); 49 void quit()
50 {
51 Stdout("Quitting").newline;
52 }
53 +/
54
55 /+
56 import tango.io.Stdout;
57
58 import qt.gui.QMainWindow;
59
60 public class TestWindow : QMainWindow
61 {
62 public this()
63 {
64 //Stdout(qVersion).newline;
65
66 //Stdout(this.children.length).newline;
67 auto box = new QDialogButtonBox(this);
68 auto closeButton = box.addButton(QDialogButtonBox.Close);
69 closeButton.clicked.connect(&onCloseClick);
70 }
27 71
28 return 5; 72 void onCloseClick()
29 // return app.exec(); 73 {
74 Stdout("Close clicked").newline;
75 }
30 } 76 }
77
78 void main(char[][] args)
79 {
80 scope app = new QApplication(args);
81 scope mainWin = new TestWindow;
82 mainWin.show();
83 return app.exec();
84 }
85 +/
86
87 /+
88
89 import qt.gui.QListWidget;
90 import qt.gui.QApplication;
91 import qt.gui.QMainWindow;
92 import tango.io.Stdout;
93 void main( char[][] args )
94 {
95
96 Stdout(qVersion).newline;
97 static void itemChanged( QListWidgetItem cur, QListWidgetItem prev )
98 {
99 if(prev )
100 {
101 Stdout("Here prev", prev, prev.__nativeId).newline;
102 prev.text; // This causes the SIGSEGV
103 Stdout("There prev").newline;
104 }
105
106 if( cur )
107 {
108 Stdout("Here", cur, cur.__nativeId).newline;
109 cur.text; // This causes the SIGSEGV
110 Stdout("There").newline;
111 }
112 }
113 scope app = new QApplication(args);
114 scope mainWin = new QMainWindow;
115 scope lw = new QListWidget( mainWin );
116 scope lwi = new QListWidgetItem("text", lw);
117 lwi.text;
118 Stdout("Here 0 ", lwi.__nativeId).newline;
119
120 lw.currentItemChanged.connect( &itemChanged );
121 mainWin.show;
122 return app.exec;
123 }
124
125 +/