案例說明
- QPixmap是用於處理圖像的控件。是優化的顯示圖像在屏幕上。
- 在我們的代碼示例中,我們將使用QPixmap窗口顯示一個圖像。
demo.go
package main
import (
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"os"
)
func InitUi() *widgets.QMainWindow {
app := widgets.NewQMainWindow(nil, 0)
app.SetWindowTitle("Qt 教程")
app.SetGeometry2(300, 300, 300, 220)
app.SetWindowIcon(gui.NewQIcon5("images/app.ico"))
widget := widgets.NewQWidget(app, core.Qt__Widget)
widget.SetGeometry2(0, 0, 300, 220)
app.SetCentralWidget(widget)
app.StatusBar()
hbox := widgets.NewQHBoxLayout2(widget)
pixmap := gui.NewQPixmap3("images/icons8-youtube.png", "", core.Qt__AutoColor)
label := widgets.NewQLabel(widget, 0)
label.SetScaledContents(true)
label.SetPixmap(pixmap)
hbox.AddWidget(label, 0, 0)
return app
}
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
app := InitUi()
app.Show()
widgets.QApplication_Exec()
}