mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-21 06:45:32 -06:00
parent
182232703b
commit
820da15d20
23 changed files with 720 additions and 33 deletions
6
samples/hosting/.gitignore
vendored
Normal file
6
samples/hosting/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
build-*/
|
||||
*.pro.user
|
||||
net-output/
|
||||
net/.idea/
|
||||
net/obj/
|
||||
net/.vs/
|
||||
13
samples/hosting/native/NativeHost.pro
Normal file
13
samples/hosting/native/NativeHost.pro
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
QT += quick
|
||||
CONFIG += c++11
|
||||
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
DEFINES += "NET_ROOT=\"\\\"$$PWD/../net-output\\\"\""
|
||||
|
||||
include (../../../src/native/QmlNet/Hosting.pri)
|
||||
18
samples/hosting/native/Page1Form.ui.qml
Normal file
18
samples/hosting/native/Page1Form.ui.qml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Page {
|
||||
width: 600
|
||||
height: 400
|
||||
|
||||
header: Label {
|
||||
text: qsTr("Page 1")
|
||||
font.pixelSize: Qt.application.font.pixelSize * 2
|
||||
padding: 10
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("You are on Page 1.")
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
18
samples/hosting/native/Page2Form.ui.qml
Normal file
18
samples/hosting/native/Page2Form.ui.qml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Page {
|
||||
width: 600
|
||||
height: 400
|
||||
|
||||
header: Label {
|
||||
text: qsTr("Page 2")
|
||||
font.pixelSize: Qt.application.font.pixelSize * 2
|
||||
padding: 10
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("You are on Page 2.")
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
}
|
||||
40
samples/hosting/native/main.cpp
Normal file
40
samples/hosting/native/main.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <Hosting/CoreHost.h>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
static int runCallback(QGuiApplication* app, QQmlApplicationEngine* engine)
|
||||
{
|
||||
engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||
if (engine->rootObjects().isEmpty())
|
||||
return -1;
|
||||
|
||||
return app->exec();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
QString netDll = NET_ROOT;
|
||||
netDll.append(QDir::separator());
|
||||
netDll.append("NetHost.dll");
|
||||
|
||||
CoreHost::RunContext runContext;
|
||||
runContext.hostFxrContext = CoreHost::findHostFxr();
|
||||
runContext.managedExe = netDll;
|
||||
// NOTE: You may set entry point to the current executable if
|
||||
// the .NET runtime is deployed side-by-side.
|
||||
runContext.entryPoint = runContext.hostFxrContext.dotnetRoot;
|
||||
runContext.entryPoint.append(CORECLR_DOTNET_EXE_NAME);
|
||||
|
||||
return CoreHost::run(app,
|
||||
engine,
|
||||
runCallback,
|
||||
runContext);
|
||||
}
|
||||
49
samples/hosting/native/main.qml
Normal file
49
samples/hosting/native/main.qml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import test 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
visible: true
|
||||
width: 640
|
||||
height: 480
|
||||
title: qsTr("Tabs")
|
||||
|
||||
SwipeView {
|
||||
id: swipeView
|
||||
anchors.fill: parent
|
||||
currentIndex: tabBar.currentIndex
|
||||
|
||||
Page1Form {
|
||||
}
|
||||
|
||||
Page2Form {
|
||||
}
|
||||
}
|
||||
|
||||
footer: TabBar {
|
||||
id: tabBar
|
||||
currentIndex: swipeView.currentIndex
|
||||
|
||||
TabButton {
|
||||
text: qsTr("Page 1")
|
||||
}
|
||||
TabButton {
|
||||
text: qsTr("Page 2")
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 500; running: true; repeat: true
|
||||
onTriggered: {
|
||||
test.testMethod()
|
||||
}
|
||||
}
|
||||
|
||||
TestObject {
|
||||
id: test
|
||||
Component.onCompleted: {
|
||||
// Call .NET
|
||||
test.testMethod()
|
||||
}
|
||||
}
|
||||
}
|
||||
9
samples/hosting/native/qml.qrc
Normal file
9
samples/hosting/native/qml.qrc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>Page1Form.ui.qml</file>
|
||||
<file>Page2Form.ui.qml</file>
|
||||
<file>main.qml</file>
|
||||
<file>qtquickcontrols2.conf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
6
samples/hosting/native/qtquickcontrols2.conf
Normal file
6
samples/hosting/native/qtquickcontrols2.conf
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
; This file can be edited to change the style of the application
|
||||
; Read "Qt Quick Controls 2 Configuration File" for details:
|
||||
; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
|
||||
|
||||
[Controls]
|
||||
Style=Default
|
||||
13
samples/hosting/net/NetHost.csproj
Normal file
13
samples/hosting/net/NetHost.csproj
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<OutDir>$(MSBuildProjectDirectory)/../net-output</OutDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\net\Qml.Net\Qml.Net.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
48
samples/hosting/net/NetHost.sln
Normal file
48
samples/hosting/net/NetHost.sln
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26124.0
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetHost", "NetHost.csproj", "{A787B77B-F87B-44A1-AD3D-38E21A92A84A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Qml.Net", "..\..\..\src\net\Qml.Net\Qml.Net.csproj", "{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A787B77B-F87B-44A1-AD3D-38E21A92A84A}.Release|x86.Build.0 = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7258C1D8-8508-4ED9-8F89-5AE2EAEBED9D}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
25
samples/hosting/net/Program.cs
Normal file
25
samples/hosting/net/Program.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Qml.Net;
|
||||
|
||||
namespace NetHost
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public class TestObject
|
||||
{
|
||||
public void TestMethod()
|
||||
{
|
||||
Console.WriteLine("test method");
|
||||
}
|
||||
}
|
||||
|
||||
static int Main(string[] _)
|
||||
{
|
||||
return Host.Run(_, (args, app, engine, runCallback) =>
|
||||
{
|
||||
QQmlApplicationEngine.RegisterType<TestObject>("test");
|
||||
return runCallback();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue