예제 #1
0
파일: calculator.go 프로젝트: mouse225/qt
func NewCalculatorForm() *widgets.QWidget {
	var widget = widgets.NewQWidget(nil, 0)

	var loader = uitools.NewQUiLoader(nil)
	var file = core.NewQFile(":/qml/calculatorform.ui")

	file.Open(core.QIODevice__ReadOnly)
	var formWidget = loader.Load(file, widget)
	file.Close()

	var (
		ui_inputSpinBox1 = widgets.NewQSpinBoxFromPointer(widget.FindChild("inputSpinBox1", core.Qt__FindChildrenRecursively))
		ui_inputSpinBox2 = widgets.NewQSpinBoxFromPointer(widget.FindChild("inputSpinBox2", core.Qt__FindChildrenRecursively))
		ui_outputWidget  = widgets.NewQLabelFromPointer(widget.FindChild("outputWidget", core.Qt__FindChildrenRecursively))
	)

	ui_inputSpinBox1.ConnectValueChanged(func(value int) {
		ui_outputWidget.SetText(fmt.Sprint(value + ui_inputSpinBox2.Value()))
	})

	ui_inputSpinBox2.ConnectValueChanged(func(value int) {
		ui_outputWidget.SetText(fmt.Sprint(value + ui_inputSpinBox1.Value()))
	})

	var layout = widgets.NewQVBoxLayout()
	layout.AddWidget(formWidget, 0, 0)
	widget.SetLayout(layout)

	widget.SetWindowTitle("Calculator Builder")

	return widget
}
예제 #2
0
파일: video_player.go 프로젝트: mouse225/qt
func newVideoPlayer() *widgets.QWidget {
	videoPlayer = widgets.NewQWidget(nil, 0)
	mediaPlayer = multimedia.NewQMediaPlayer(nil, multimedia.QMediaPlayer__VideoSurface)

	var (
		videoWidget = multimediawidgets.NewQVideoWidget(nil)
		openButton  = widgets.NewQPushButton2("Open...", nil)
	)
	openButton.ConnectClicked(func(_ bool) { openFile() })

	playButton = widgets.NewQPushButton(nil)
	playButton.SetEnabled(false)
	playButton.SetIcon(videoPlayer.Style().StandardIcon(widgets.QStyle__SP_MediaPlay, nil, nil))
	playButton.ConnectClicked(func(_ bool) { play() })

	positionsSlider = widgets.NewQSlider2(core.Qt__Horizontal, nil)
	positionsSlider.SetRange(0, 0)
	positionsSlider.ConnectSliderMoved(setPosition)

	errorLabel = widgets.NewQLabel(nil, 0)
	errorLabel.SetTextFormat(core.Qt__RichText)
	errorLabel.SetSizePolicy2(widgets.QSizePolicy__Preferred, widgets.QSizePolicy__Maximum)

	var controlLayout = widgets.NewQHBoxLayout()
	controlLayout.SetContentsMargins(0, 0, 0, 0)
	controlLayout.AddWidget(openButton, 0, 0)
	controlLayout.AddWidget(playButton, 0, 0)
	controlLayout.AddWidget(positionsSlider, 0, 0)

	var layout = widgets.NewQVBoxLayout()
	layout.AddWidget(videoWidget, 0, 0)
	layout.AddLayout(controlLayout, 0)
	layout.AddWidget(errorLabel, 0, 0)

	videoPlayer.SetLayout(layout)

	mediaPlayer.SetVideoOutput(videoWidget.Pointer())
	mediaPlayer.ConnectStateChanged(mediaStateChanged)
	mediaPlayer.ConnectPositionChanged(positionChanged)
	mediaPlayer.ConnectDurationChanged(durationChanged)
	mediaPlayer.ConnectError2(handleError)

	return videoPlayer
}
예제 #3
0
func NewCanvas() *widgets.QWidget {
	canvas = widgets.NewQWidget(nil, 0)
	scene = widgets.NewQGraphicsScene(nil)
	view = widgets.NewQGraphicsView(nil)

	var font = gui.NewQFont2("Meiryo", 20, 2, false)
	scene.AddText("Hello 世界", font)

	var color = gui.NewQColor2(255, 0, 0, 255)
	var pen = gui.NewQPen3(color)

	scene.AddLine2(0, scene.Height(), scene.Width(), scene.Height(), pen)

	view.SetScene(scene)

	var layout = widgets.NewQVBoxLayout()
	layout.AddWidget(view, 0, 0)

	canvas.SetLayout(layout)

	return canvas
}