zoukankan      html  css  js  c++  java
  • golang + qt5 开发GUI程序

    package main
    
    import (
        "os"
        "ttqt/uigen"
    
        "fmt"
        "github.com/therecipe/qt/core"
        "github.com/therecipe/qt/widgets"
    )
    
    func main() {
        _translate := core.QCoreApplication_Translate
        app := widgets.NewQApplication(len(os.Args), os.Args)
    
        // 创建窗口
        window := widgets.NewQMainWindow(nil, 0)
    
        // 显示窗口
        window.Show()
    
        // 加载UI界面
        var win uigen.UIMainwindowMainWindow
    
        // 绑定
        win.SetupUI(window)
    
        // ---------------------- 测试事件绑定 --------------
        // 设置按钮触发,触发退出程序
        win.PushButtonStartCheck.ConnectClicked(func(checked bool) {
            fmt.Println("点击按钮,开始检测")
            win.LabelCheck01.SetText(_translate("MainWindow", RedFont("不通过"), "", -1))
        })
    
        win.PushButtonCloseWindow.ConnectClicked(func(checked bool) {
            fmt.Println("关闭窗口,按钮")
            window.Close()
        })
        // ---------------  启动程序 ----------------
        app.Exec()
    
    }
    
    func RedFont(text string) string {
        s := fmt.Sprintf("<html><head/><body><p><span style=" color:#ff0000;">%v</span></p></body></html>", text)
        return s
    }
    
    // func main() {
    //     app := widgets.NewQApplication(len(os.Args), os.Args)
    //
    //     // 创建窗口
    //     window := widgets.NewQMainWindow(nil, 0)
    //
    //     // 设置大小
    //     window.SetMinimumSize2(500, 500)
    //
    //     // 设置窗口标题
    //     window.SetWindowTitle("U盘质量检测工具  --44开发")
    //
    //     // 显示窗口
    //     window.Show()
    //
    //     app.Exec()
    // }

    使用工具,.ui -> .go

    #!/bin/bash
    
    # ui界面界面文件生成go语言代码
    goqtuic -ui-file mainwindow.ui


    编译,运行

    #!/bin/bash
    
    # 编译
    qtdeploy build linux ttqt
    
    # 运行
    ./deploy/linux/ttqt

    参考: https://www.cnblogs.com/apocelipes/p/9300335.html

  • 相关阅读:
    PHP 高精度计算
    PHPWord使用方法
    羽毛球
    大数据(2)
    大数据(1)
    Centos 7 启动错误:XFS_WANT_CORRUPTED_GOTO 修复
    selenium 自动化工具
    python 开发技巧(0)-- 各个系统的python安装
    Yii简单使用阿里云短信教程!
    VMware虚拟机 Ubuntu 实用技巧 (2)桥接模式连接网络与网卡的配置
  • 原文地址:https://www.cnblogs.com/jiftle/p/12567748.html
Copyright © 2011-2022 走看看