static int Main(string[] args) { RuntimeManager.DiscoverOrDownloadSuitableQtRuntime(); using (var app = new QGuiApplication(args)) { Qml.Net.Qml.RegisterType <Trans>("TaoQuickNet"); var trans = new Trans(); trans.loadFolder(Config.Config.transPath); using (var engine = new QQmlApplicationEngine()) { Console.WriteLine("importPath " + Config.Config.importPath); Console.WriteLine("imgPath " + Config.Config.imgPath); engine.AddImportPath(Config.Config.importPath); engine.SetContextProperty("imgPath", Config.Config.imgPath); engine.SetContextProperty("qmlPath", Config.Config.qmlPath); engine.SetContextProperty("contentsPath", Config.Config.contentsPath); engine.SetContextProperty("isDebug", true); engine.SetContextProperty("taoQuickImagePath", Config.Config.importPath + "TaoQuick/Images/"); engine.SetContextProperty("trans", trans); engine.Load(Config.Config.qmlPath + "main.qml"); return(app.Exec()); } } }
protected virtual void AddImportPath(QQmlApplicationEngine engine) { if (Builder.ImportPath.Count() == 0) { return; } foreach (var path in Builder.ImportPath) { engine.AddImportPath(path); } }
static int Main(string[] args) { using (var app = new QGuiApplication(args)) { using (var engine = new QQmlApplicationEngine()) { engine.AddImportPath(Path.Combine(Directory.GetCurrentDirectory(), "Qml")); Qml.RegisterType <TestQmlImport>("test"); engine.Load("main.qml"); return(app.Exec()); } } }