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 (
"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()

View File

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