seperate cell for dynamic creation (there may be a better way but im lazy)

This commit is contained in:
lordwelch 2016-01-14 18:42:52 -08:00
parent f7f8ff2c57
commit 0362fd2227
3 changed files with 66 additions and 26 deletions

27
cell.qml Normal file
View File

@ -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
}
}

17
main.go
View File

@ -4,11 +4,16 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path/filepath"
"github.com/kardianos/osext" "github.com/kardianos/osext"
"gopkg.in/qml.v1" "gopkg.in/qml.v1"
) )
var (
path string
)
func main() { func main() {
if err := qml.Run(run); err != nil { if err := qml.Run(run); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err) fmt.Fprintf(os.Stderr, "error: %v\n", err)
@ -19,13 +24,19 @@ func main() {
func run() error { func run() error {
engine := qml.NewEngine() engine := qml.NewEngine()
path, err := osext.ExecutableFolder() 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 { if err != nil {
return err return err
} }
window := controls.CreateWindow(nil) cellQml, err := engine.LoadFile(path + "/cell.qml")
window.ObjectByName("data1") if err != nil {
return err
}
window := mainQml.CreateWindow(nil)
window.Show() window.Show()
window.Wait() window.Wait()

View File

@ -9,6 +9,8 @@ ApplicationWindow {
minimumWidth: 500 minimumWidth: 500
minimumHeight: 500 minimumHeight: 500
property int globalForJs: 10 property int globalForJs: 10
width: 1000
height: 600
SplitView { SplitView {
id: mainSlider id: mainSlider
objectName: "mainSlider" objectName: "mainSlider"
@ -65,34 +67,34 @@ ApplicationWindow {
anchors.left: parent.left anchors.left: parent.left
} }
} }
}
Rectangle { Rectangle {
id: col2 id: col2
objectName: "col2" objectName: "col2"
color: "#4f90e2" color: "#4f90e2"
border.width: 0 border.width: 0
Column { Column {
id: data2 id: data2
objectName: "data2" objectName: "data2"
anchors.fill: parent anchors.fill: parent
}
} }
} }
} }
}
Rectangle { Rectangle {
id: mainView id: mainView
objectName: "mainView" objectName: "mainView"
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 0 anchors.rightMargin: 0
anchors.leftMargin: 0 anchors.leftMargin: 0
anchors.left: gridRect.right anchors.left: gridRect.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.top: parent.top anchors.top: parent.top
z: 1 z: 1
clip: false clip: false
visible: true visible: true
}
} }
} }