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 (p *MainWindow) createToolBox() qt5.IWidget {
	tb := qt5.NewToolBox()
	tb.AddItem(qt5.NewButtonWithText("button"), "btn", nil)
	tb.AddItem(qt5.NewLabelWithText("Label\nInfo"), "Label", nil)
	pixmap := qt5.NewPixmapWithFile("images/liteide128.png")
	//defer pixmap.Close()
	lbl := qt5.NewLabel()
	lbl.SetPixmap(pixmap)
	tb.AddItem(lbl, "Lalel Pixmap", nil)
	buf, err := ioutil.ReadFile("images/liteide128.png")
	if err == nil {
		pixmap2 := qt5.NewPixmapWithData(buf)
		tb.AddItem(qt5.NewLabelWithPixmap(pixmap2), "Lalel Pixmap2", nil)
	}
	return tb
}
Exemple #3
0
func (p *MainWindow) createMyTab() *qt5.Widget {
	w := qt5.NewWidget()
	vbox := qt5.NewVBoxLayout()
	hbox := qt5.NewHBoxLayout()
	my := new(MyWidget).Init()
	lbl := qt5.NewLabel()
	lbl.SetText("this is custome widget - draw lines")
	btn := qt5.NewButton()
	btn.SetText("Clear")
	btn.OnClicked(func() {
		my.Clear()
	})
	hbox.AddWidget(lbl)
	hbox.AddWidgetWith(btn, 0, qt5.AlignRight)
	vbox.AddLayout(hbox)
	vbox.AddWidgetWith(my, 1, 0)
	w.SetLayout(vbox)
	return w
}