aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-07-05 15:11:13 +0200
committerAdrian Kummerlaender2015-07-05 15:14:00 +0200
commit78966dc00419a4f5fe5fec4725062a4a0f380228 (patch)
treeb57fd0ac94d385f72c8cfffa0f034a27459fb93e
parent77220db5d2ef2eee22f8456527f2ae66ea457685 (diff)
downloadMetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.gz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.bz2
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.lz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.xz
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.tar.zst
MetaTerm-78966dc00419a4f5fe5fec4725062a4a0f380228.zip
Embedded QML into C++ application
-rw-r--r--MetaTerm.pro7
-rw-r--r--main.cpp19
-rw-r--r--qml/EmbeddedTerminal.qml (renamed from EmbeddedTerminal.qml)0
-rw-r--r--qml/ScrollBar.qml (renamed from ScrollBar.qml)0
-rw-r--r--qml/TerminalItem.qml (renamed from TerminalItem.qml)6
-rw-r--r--qml/main.qml (renamed from MetaTerm.qml)16
-rw-r--r--qml/ui.qrc8
7 files changed, 45 insertions, 11 deletions
diff --git a/MetaTerm.pro b/MetaTerm.pro
new file mode 100644
index 0000000..532ba39
--- /dev/null
+++ b/MetaTerm.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+
+QT += qml quick widgets
+
+SOURCES += main.cpp
+
+RESOURCES += qml/ui.qrc
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..8f7eafc
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,19 @@
+#include <QApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ QQmlApplicationEngine engine;
+
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+
+ QObject::connect(
+ static_cast<QObject*>(&engine),
+ SIGNAL(quit()),
+ static_cast<QObject*>(&app),
+ SLOT(quit())
+ );
+
+ return app.exec();
+}
diff --git a/EmbeddedTerminal.qml b/qml/EmbeddedTerminal.qml
index f4f104e..f4f104e 100644
--- a/EmbeddedTerminal.qml
+++ b/qml/EmbeddedTerminal.qml
diff --git a/ScrollBar.qml b/qml/ScrollBar.qml
index 18f149c..18f149c 100644
--- a/ScrollBar.qml
+++ b/qml/ScrollBar.qml
diff --git a/TerminalItem.qml b/qml/TerminalItem.qml
index 883d911..6c19c45 100644
--- a/TerminalItem.qml
+++ b/qml/TerminalItem.qml
@@ -47,7 +47,7 @@ Item {
id: elementList
function createTerminal(program) {
- var terminal = Qt.createComponent("EmbeddedTerminal.qml");
+ var terminal = Qt.createComponent("qrc:/EmbeddedTerminal.qml");
var instantiateTerminal = function() {
terminal.createObject(elementList, {
"columns": 90,
@@ -58,11 +58,11 @@ Item {
});
}
- if ( terminal.status == Component.Ready ) {
+ if ( terminal.status === Component.Ready ) {
instantiateTerminal();
} else {
terminal.statusChanged.connect(instantiateTerminal);
- }
+ }
}
RowLayout {
diff --git a/MetaTerm.qml b/qml/main.qml
index 9ee41a3..1e0db9d 100644
--- a/MetaTerm.qml
+++ b/qml/main.qml
@@ -1,11 +1,11 @@
import QtQuick 2.0
-import QMLTermWidget 1.0
+import QtQuick.Window 2.0
import QtQuick.Controls 1.2
-
-Rectangle {
+ApplicationWindow {
id: root
- anchors.fill: parent
+
+ visible: true
color: "#161616"
@@ -29,7 +29,7 @@ Rectangle {
onHeightChanged: scrollTo(activeItem)
function createItem() {
- var terminalItem = Qt.createComponent("TerminalItem.qml");
+ var terminalItem = Qt.createComponent("qrc:/TerminalItem.qml");
var instantiateTerminal = function() {
var instance = terminalItem.createObject(terminalList, {
"width": terminalListFlickable.width
@@ -37,7 +37,7 @@ Rectangle {
instance.onExecuted.connect(createItem);
}
- if ( terminalItem.status == Component.Ready ) {
+ if ( terminalItem.status === Component.Ready ) {
instantiateTerminal();
} else {
terminalItem.statusChanged.connect(instantiateTerminal);
@@ -98,7 +98,7 @@ Rectangle {
width: terminalListFlickable.width
onExecuted: terminalList.createItem()
}
- }
+ }
}
Action {
@@ -128,7 +128,7 @@ Rectangle {
lastTerminalAction.enabled = true;
firstTerminalAction.enabled = true;
- root.forceActiveFocus();
+ terminalList.forceActiveFocus();
terminalList.unfocusCurrent();
}
}
diff --git a/qml/ui.qrc b/qml/ui.qrc
new file mode 100644
index 0000000..8339fa2
--- /dev/null
+++ b/qml/ui.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>TerminalItem.qml</file>
+ <file>EmbeddedTerminal.qml</file>
+ <file>ScrollBar.qml</file>
+ </qresource>
+</RCC>