go qt的设置(windows)

使用Go语言开发Qt界面_go qt_kuokay的博客-CSDN博客

# Go的环境变量配置,配置过一次就不用在设置了
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn

go的版本是1.19.2

# 下载therecipe/qt库
go get -v -tags=no_env github.com/therecipe/qt/cmd/...

 

 

windows 就是系统变量

package main

import (
   "os"

   "github.com/therecipe/qt/widgets"
)

func main() {

   // needs to be called once before you can start using the QWidgets
   app := widgets.NewQApplication(len(os.Args), os.Args)

   // create a window
   // with a minimum size of 250*200
   // and sets the title to "Hello Widgets Example"
   window := widgets.NewQMainWindow(nil, 0)
   window.SetMinimumSize2(250, 200)
   window.SetWindowTitle("Hello Widgets Example")

   // create a regular widget
   // give it a QVBoxLayout
   // and make it the central widget of the window
   widget := widgets.NewQWidget(nil, 0)
   widget.SetLayout(widgets.NewQVBoxLayout())
   window.SetCentralWidget(widget)

   // create a line edit
   // with a custom placeholder text
   // and add it to the central widgets layout
   input := widgets.NewQLineEdit(nil)
   input.SetPlaceholderText("Write something ...")
   widget.Layout().AddWidget(input)

   // create a button
   // connect the clicked signal
   // and add it to the central widgets layout
   button := widgets.NewQPushButton2("and click me!", nil)
   button.ConnectClicked(func(bool) {
      widgets.QMessageBox_Information(nil, "OK", input.Text(), widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
   })
   widget.Layout().AddWidget(button)

   // make the window visible
   window.Show()

   // start the main Qt event loop
   // and block until app.Exit() is called
   // or the window is closed by the user
   app.Exec()
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值