Exemple #1
0
func (p *MainWindow) createStdTab() *qt5.Widget {
	w := qt5.NewWidget()
	vbox := qt5.NewVBoxLayout()
	w.SetLayout(vbox)

	ed := qt5.NewLineEdit()
	ed.SetInputMask("0000-00-00")
	ed.SetText("2012-01-12")

	lbl := qt5.NewLabel()
	lbl.SetText("Label")
	btn := qt5.NewButton()
	btn.SetText("Button")
	chk := qt5.NewCheckBox()
	chk.SetText("CheckBox")
	radio := qt5.NewRadio()
	radio.SetText("Radio")
	cmb := qt5.NewComboBox()
	cmb.AddItem("001")
	cmb.AddItem("002")
	cmb.AddItem("003")
	cmb.SetCurrentIndex(2)
	fmt.Println(cmb.CurrentIndex())
	cmb.OnCurrentIndexChanged(func(v int) {
		fmt.Println(cmb.ItemText(v))
	})

	slider := qt5.NewSlider()
	slider.SetTickInterval(50)
	slider.SetTickPosition(qt5.TicksBothSides)
	slider.SetSingleStep(1)

	scl := qt5.NewScrollBar()
	fmt.Println(slider.Range())

	dial := qt5.NewDial()

	dial.SetNotchesVisible(true)
	dial.SetNotchTarget(10)
	fmt.Println(dial.NotchSize())

	vbox.AddWidget(ed)
	vbox.AddWidget(lbl)
	vbox.AddWidget(btn)
	vbox.AddWidget(chk)
	vbox.AddWidget(radio)
	vbox.AddWidget(cmb)
	vbox.AddWidget(slider)
	vbox.AddWidget(scl)
	vbox.AddWidget(dial)
	vbox.AddStretch(0)
	return w
}
Exemple #2
0
func ui_main() {

	w := qt5.NewWidget()

	lbox := qt5.NewVBoxLayout()
	lbl1 := qt5.NewLabel()
	lbl1.SetText("This is a info1")
	lbl2 := qt5.NewLabel()
	lbl2.SetText("This is a info2")

	ed1 := qt5.NewLineEdit()

	printInfo := func() {
		info := qt5.Value("info")
		ed1.SetText(fmt.Sprint(info))
	}

	lbox.AddWidget(lbl1)
	lbox.AddWidget(lbl2)
	lbox.AddWidget(ed1)

	rbox := qt5.NewVBoxLayout()

	btn1 := qt5.NewButton()
	btn1.SetText("Change")

	btn2 := qt5.NewButton()
	btn2.SetText("Value")

	btn3 := qt5.NewButton()
	btn3.SetText("SetValue")

	rbox.AddWidget(btn1)
	rbox.AddWidget(btn2)
	rbox.AddWidget(btn3)

	b := true
	btn1.OnClicked(func() {
		var text string
		if b {
			qt5.SetKey(lbl1, "info", "text")
			text = "info1"
		} else {
			qt5.SetKey(lbl2, "info", "text")
			text = "info2"
		}
		b = !b
		btn1.SetText(text)
	})

	btn2.OnClicked(printInfo)
	btn3.OnClicked(setInfo)

	hbox := qt5.NewHBoxLayout()
	hbox.AddLayout(lbox)
	hbox.AddLayout(rbox)

	w.SetLayout(hbox)

	w.Show()

	qt5.Run()
}