Esempio n. 1
0
File: main.go Progetto: gooops/goqt
func main() {
	ui.Run(func() {
		info := fmt.Sprintf("GoQt Version %v \nQt Version %v\ngo verison %v %v/%v",
			ui.Version(),
			ui.QtVersion(),
			runtime.Version(), runtime.GOOS, runtime.GOARCH)

		lable := ui.NewQLabel()
		lable.SetText(info)

		hbox := ui.NewQHBoxLayout()
		hbox.AddWidget(lable)

		widget := ui.NewQWidget()
		widget.SetLayout(hbox)
		widget.Show()
	})
}
Esempio n. 2
0
File: main.go Progetto: gooops/goqt
func main_ui() {
	btn := ui.NewQPushButton()
	btn.SetText("Async")

	clear := ui.NewQPushButton()
	clear.SetText("Clear")

	edit := ui.NewQPlainTextEdit()
	edit.SetReadOnly(true)

	btn.OnClicked(func() {
		for i := 0; i < 10; i++ {
			go func(i int) {
				start := time.Now()
				<-time.After(1e7)
				offset := time.Now().Sub(start)
				ui.Async(func() {
					edit.AppendPlainText(fmt.Sprintf("Task %v %v", i, offset))
				})
			}(i)
		}
	})

	clear.OnClicked(func() {
		edit.Clear()
	})

	hbox := ui.NewQHBoxLayout()
	hbox.AddWidget(btn)
	hbox.AddWidget(clear)

	vbox := ui.NewQVBoxLayout()
	vbox.AddLayout(hbox)
	vbox.AddWidget(edit)

	widget := ui.NewQWidget()
	widget.SetLayout(vbox)
	widget.Show()
}
Esempio n. 3
0
func NewCodeEdit() *CodeEdit {
	w := &CodeEdit{}
	w.QWidget = ui.NewQWidget()
	w.edit = ui.NewQPlainTextEdit()
	w.edit.SetLineWrapMode(ui.QPlainTextEdit_NoWrap)
	w.syntax = ui.NewQSyntaxHighlighterHookWithDoc(w.edit.Document())
	w.lineArea = ui.NewQWidget()
	w.lineArea.SetFixedWidth(0)

	hbox := ui.NewQHBoxLayout()
	hbox.SetMargin(0)
	hbox.SetSpacing(0)
	hbox.AddWidget(w.lineArea)
	hbox.AddWidget(w.edit)
	w.SetLayout(hbox)

	w.lineArea.InstallEventFilter(w)

	w.edit.OnBlockCountChanged(func(int32) {
		w.UpdateLineNumberAreaWidth()
		w.lineArea.Update()
	})
	w.edit.OnUpdateRequest(func(*ui.QRect, int32) {
		w.lineArea.Update()
	})

	w.UpdateLineNumberAreaWidth()

	w.MakeRules()

	w.syntax.OnHighlightBlock(w.OnHighlightBlock)

	font := w.edit.Font()
	font.SetPointSize(12)
	w.edit.SetFont(font)
	w.lineArea.SetFont(font)

	return w
}