2014-07-19 18:26:08 +02:00
|
|
|
import std.stdio;
|
|
|
|
import std.string;
|
|
|
|
import std.traits;
|
|
|
|
import std.conv;
|
|
|
|
import std.functional;
|
2014-08-30 21:46:15 +02:00
|
|
|
import core.memory;
|
2014-07-19 18:26:08 +02:00
|
|
|
import dotherside;
|
|
|
|
|
2014-12-30 19:11:01 +01:00
|
|
|
class MyObject : QObject
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
|
|
|
this()
|
|
|
|
{
|
2014-08-30 18:46:34 +02:00
|
|
|
foo = registerSlot("foo", &_foo);
|
2014-07-19 18:26:08 +02:00
|
|
|
bar = registerSlot("bar", &_bar);
|
2014-08-30 21:46:15 +02:00
|
|
|
nameChanged = registerSignal!(string)("nameChanged");
|
2014-08-30 18:46:34 +02:00
|
|
|
tor = registerSlot("tor", &_tor);
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-12-30 19:11:01 +01:00
|
|
|
public QSlot!(void delegate(int)) foo;
|
|
|
|
private void _foo(int fooValue)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-07-20 17:05:52 +02:00
|
|
|
writeln("D: Called foo slot with argument ", fooValue , "!!");
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
2014-12-30 19:11:01 +01:00
|
|
|
public QSlot!(int delegate(int)) bar;
|
|
|
|
private int _bar(int barValue)
|
2014-07-19 18:26:08 +02:00
|
|
|
{
|
2014-07-20 17:05:52 +02:00
|
|
|
writeln("D: Called bar slot with argument " , barValue, "!!");
|
2014-07-19 18:26:08 +02:00
|
|
|
return 666;
|
|
|
|
}
|
2014-08-30 18:46:34 +02:00
|
|
|
|
2014-12-30 19:11:01 +01:00
|
|
|
public QSlot!(string delegate(string)) tor;
|
|
|
|
private string _tor (string torValue)
|
2014-08-30 18:46:34 +02:00
|
|
|
{
|
|
|
|
writeln("D: Called tor slot with argument ", torValue, "!!");
|
|
|
|
return "2343";
|
|
|
|
}
|
|
|
|
|
2014-12-30 19:11:01 +01:00
|
|
|
public QSignal!(string) nameChanged;
|
2014-07-19 18:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-12-01 21:30:45 +01:00
|
|
|
auto app = new QGuiApplication;
|
2014-12-29 21:19:33 +01:00
|
|
|
scope(exit) destroy(app);
|
2014-08-30 18:46:34 +02:00
|
|
|
|
2014-12-01 21:30:45 +01:00
|
|
|
auto view = new QQuickView;
|
2014-12-29 21:19:33 +01:00
|
|
|
scope(exit) destroy(view);
|
2014-07-19 18:26:08 +02:00
|
|
|
|
|
|
|
auto myObject = new MyObject();
|
2014-12-29 21:19:33 +01:00
|
|
|
scope(exit) destroy(myObject);
|
2014-07-19 18:26:08 +02:00
|
|
|
|
|
|
|
auto context = view.rootContext();
|
|
|
|
context.setContextProperty("myObject", new QVariant(myObject));
|
|
|
|
|
|
|
|
view.setSource("Test.qml");
|
|
|
|
view.show();
|
2014-08-30 18:46:34 +02:00
|
|
|
|
|
|
|
myObject.nameChanged("prova");
|
|
|
|
|
2014-07-19 18:26:08 +02:00
|
|
|
app.exec();
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{}
|
|
|
|
}
|