From 0362fd22278ee3ec7f83d847aa49ae93e9aab53b Mon Sep 17 00:00:00 2001 From: lordwelch Date: Thu, 14 Jan 2016 18:42:52 -0800 Subject: [PATCH] seperate cell for dynamic creation (there may be a better way but im lazy) --- cell.qml | 27 +++++++++++++++++++++++++++ main.go | 17 ++++++++++++++--- main.qml | 48 +++++++++++++++++++++++++----------------------- 3 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 cell.qml diff --git a/cell.qml b/cell.qml new file mode 100644 index 0000000..de521af --- /dev/null +++ b/cell.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + property int index: 0 + + Text { + id: cellText + height: 75 + text: "hello this is text\nhaha\nhdsjfklfhaskjd" + textFormat: Text.AutoText + clip: true + font.bold: false + anchors.fill: parent + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignTop + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.left: parent.left + anchors.leftMargin: 0 + font.pixelSize: 12 + MouseArea { + id: cellMouse + anchors.fill: parent + } + } + diff --git a/main.go b/main.go index 454ca65..7619beb 100644 --- a/main.go +++ b/main.go @@ -4,11 +4,16 @@ package main import ( "fmt" "os" + "path/filepath" "github.com/kardianos/osext" "gopkg.in/qml.v1" ) +var ( + path string +) + func main() { if err := qml.Run(run); err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) @@ -19,13 +24,19 @@ func main() { func run() error { engine := qml.NewEngine() path, err := osext.ExecutableFolder() - controls, err := engine.LoadFile(path + "/../share/main.qml") + path = filepath.Clean(path + "/../src/github.com/lordwelch/PresentationApp/") + fmt.Println(path) + mainQml, err := engine.LoadFile(path + "/main.qml") if err != nil { return err } - window := controls.CreateWindow(nil) - window.ObjectByName("data1") + cellQml, err := engine.LoadFile(path + "/cell.qml") + if err != nil { + return err + } + + window := mainQml.CreateWindow(nil) window.Show() window.Wait() diff --git a/main.qml b/main.qml index 535b713..959554b 100644 --- a/main.qml +++ b/main.qml @@ -9,6 +9,8 @@ ApplicationWindow { minimumWidth: 500 minimumHeight: 500 property int globalForJs: 10 + width: 1000 + height: 600 SplitView { id: mainSlider objectName: "mainSlider" @@ -65,34 +67,34 @@ ApplicationWindow { anchors.left: parent.left } } + } - Rectangle { - id: col2 - objectName: "col2" - color: "#4f90e2" - border.width: 0 + Rectangle { + id: col2 + objectName: "col2" + color: "#4f90e2" + border.width: 0 - Column { - id: data2 - objectName: "data2" - anchors.fill: parent - } + Column { + id: data2 + objectName: "data2" + anchors.fill: parent } } } + } - Rectangle { - id: mainView - objectName: "mainView" - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.leftMargin: 0 - anchors.left: gridRect.right - anchors.bottom: parent.bottom - anchors.top: parent.top - z: 1 - clip: false - visible: true - } + Rectangle { + id: mainView + objectName: "mainView" + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.leftMargin: 0 + anchors.left: gridRect.right + anchors.bottom: parent.bottom + anchors.top: parent.top + z: 1 + clip: false + visible: true } }