windows下 go安装qt绑定

2023-05-16

 1.下载安装QT

离线版QT地址:  https://download.qt.io/official_releases/qt/5.11/5.11.1/qt-opensource-windows-x86-5.11.1.exe

注意

最好全部安装,否则在后续的安装过程中会提示相应的文件找不到

 

2. 在环境变量中指定QT_DIR

默认的QT_DIR为C:\Qt

如果不指定QT_DIR,在后续安装过程中会出现如下错误

3. 将g++所在路径加入环境变量PATH中


C:\Qt\Qt5.11.1\Tools\mingw530_32\bin
C:\Qt\Qt5.11.1\5.11.1\mingw53_32\bin
C:\Qt\Qt5.11.1\Tools\mingw530_32\opt\bin  


C:\Qt\Qt5.11.1\Tools\mingw530_32\bin 目录下包含了gcc、g++等编译链接工具

C:\Qt\Qt5.11.1\5.11.1\mingw53_32\bin 目录下包含了qmake.exe以及程序运行过程中需要的动态链接库(.dll)文件

4. 安装go 

下载地址: https://golang.org/dl/

5. 下载安装therecipe/qt


# 下载
go get -v github.com/therecipe/qt/cmd/...
# 安装
%GOPATH%\bin\qtsetup.exe  

安装过程中出现的硬链接失败可以忽略

生成的静态库所在路径为: %GOPATH%\pkg\windows_386\github.com\therecipe\qt

总共预计安装39个静态库文件(后缀名为.a)。其中安装成功38个,安装失败1个(winextras)。

安装记录如下:


F:\>qtsetup
[36mINFO[0m[0000] running: 'qtsetup prep'
[31mERRO[0m[0000] failed to run command                         [31mcmd[0m="cmd /C mklink /H C:\\Go\\bin\\qtrcc.exe F:\\Workspace\\go\\bin\\qtrcc.exe" [31mdir[0m= [31menv[0m= [31merror[0m="exit status 1" [31mfunc[0m=RunCmdOptional [31mname[0m="failed to create qtrcc symlink in your PATH (C:\\Go\\bin\\qtrcc.exe); please use F:\\Workspace\\go\\bin\\qtrcc.exe instead"
ϵͳ�޷����ļ��Ƶ���ͬ�Ĵ�����������

[31mERRO[0m[0000] failed to run command                         [31mcmd[0m="cmd /C mklink /H C:\\Go\\bin\\qtmoc.exe F:\\Workspace\\go\\bin\\qtmoc.exe" [31mdir[0m= [31menv[0m= [31merror[0m="exit status 1" [31mfunc[0m=RunCmdOptional [31mname[0m="failed to create qtmoc symlink in your PATH (C:\\Go\\bin\\qtmoc.exe); please use F:\\Workspace\\go\\bin\\qtmoc.exe instead"
ϵͳ�޷����ļ��Ƶ���ͬ�Ĵ�����������

[31mERRO[0m[0000] failed to run command                         [31mcmd[0m="cmd /C mklink /H C:\\Go\\bin\\qtminimal.exe F:\\Workspace\\go\\bin\\qtminimal.exe" [31mdir[0m= [31menv[0m= [31merror[0m="exit status 1" [31mfunc[0m=RunCmdOptional [31mname[0m="failed to create qtminimal symlink in your PATH (C:\\Go\\bin\\qtminimal.exe); please use F:\\Workspace\\go\\bin\\qtminimal.exe instead"
ϵͳ�޷����ļ��Ƶ���ͬ�Ĵ�����������

[31mERRO[0m[0000] failed to run command                         [31mcmd[0m="cmd /C mklink /H C:\\Go\\bin\\qtdeploy.exe F:\\Workspace\\go\\bin\\qtdeploy.exe" [31mdir[0m= [31menv[0m= [31merror[0m="exit status 1" [31mfunc[0m=RunCmdOptional [31mname[0m="failed to create qtdeploy symlink in your PATH (C:\\Go\\bin\\qtdeploy.exe); please use F:\\Workspace\\go\\bin\\qtdeploy.exe instead"
ϵͳ�޷����ļ��Ƶ���ͬ�Ĵ�����������

[36mINFO[0m[0000] running: 'qtsetup check windows' [docker=false] [vagrant=false]
[36mINFO[0m[0000] GOOS:                        'windows'
[36mINFO[0m[0000] GOARCH:                      'amd64'
[36mINFO[0m[0000] GOVERSION:                   'go1.10.1'
[36mINFO[0m[0000] GOROOT:                   *  'C:\Go\'
[36mINFO[0m[0000] GOPATH:                   *  'F:\Workspace\go'
[36mINFO[0m[0000] GOBIN:                       'F:\Workspace\go\bin'
[36mINFO[0m[0000] QT_HASH:                     'd0f30a6e4c39e0989b1b00169b66abbca442becf'
[36mINFO[0m[0000] QT_VERSION:                  '5.11.1'
[36mINFO[0m[0000] QT_VERSION_MAJOR:            '5.11.1'
[36mINFO[0m[0000] QT_DIR:                   *  'C:\Qt\Qt5.11.1'
[36mINFO[0m[0000] QT_STUB:                     'false'
[36mINFO[0m[0000] QT_DEBUG:                    'false'
[36mINFO[0m[0000] QT_QMAKE_DIR:                ''
[36mINFO[0m[0000] QT_WEBKIT:                   'false'
[36mINFO[0m[0000] QT_MSYS2:                    'false'
[36mINFO[0m[0000] running: 'qtsetup generate windows' [docker=false] [vagrant=false]
[36mINFO[0m[0006] generating full qt/core
[36mINFO[0m[0013] generating full qt/androidextras
[36mINFO[0m[0013] generating full qt/gui
[36mINFO[0m[0036] generating full qt/network
[36mINFO[0m[0039] generating full qt/xml
[36mINFO[0m[0041] generating full qt/dbus
[36mINFO[0m[0043] generating full qt/nfc
[36mINFO[0m[0044] generating full qt/script
[36mINFO[0m[0046] generating full qt/sensors
[36mINFO[0m[0049] generating full qt/positioning
[36mINFO[0m[0050] generating full qt/widgets
[36mINFO[0m[0071] generating full qt/sql
[36mINFO[0m[0073] generating full qt/qml
[36mINFO[0m[0075] generating full qt/websockets
[36mINFO[0m[0076] generating full qt/xmlpatterns
[36mINFO[0m[0078] generating full qt/bluetooth
[36mINFO[0m[0080] generating full qt/webchannel
[36mINFO[0m[0081] generating full qt/svg
[36mINFO[0m[0083] generating full qt/multimedia
[36mINFO[0m[0089] generating full qt/quick
[36mINFO[0m[0092] generating full qt/help
[36mINFO[0m[0095] generating full qt/location
[36mINFO[0m[0096] generating full qt/scripttools
[36mINFO[0m[0097] generating full qt/uitools
[36mINFO[0m[0099] generating full qt/winextras
[36mINFO[0m[0100] generating full qt/testlib
[36mINFO[0m[0101] generating full qt/serialport
[36mINFO[0m[0102] generating full qt/serialbus
[36mINFO[0m[0104] generating full qt/printsupport
[36mINFO[0m[0106] generating full qt/designer
[36mINFO[0m[0110] generating full qt/scxml
[36mINFO[0m[0112] generating full qt/gamepad
[36mINFO[0m[0113] generating full qt/purchasing
[36mINFO[0m[0114] generating full qt/datavisualization
[36mINFO[0m[0117] generating full qt/charts
[36mINFO[0m[0122] generating full qt/speech
[36mINFO[0m[0123] generating full qt/quickcontrols2
[36mINFO[0m[0124] generating full qt/sailfish
[36mINFO[0m[0124] generating full qt/remoteobjects
[36mINFO[0m[0125] running: 'qtsetup install windows' [docker=false] [vagrant=false]
[36mINFO[0m[0125] installing full qt/core
[36mINFO[0m[0126] installing full qt/androidextras
[36mINFO[0m[0127] installing full qt/gui
[36mINFO[0m[0128] installing full qt/network
[36mINFO[0m[0128] installing full qt/xml
[36mINFO[0m[0129] installing full qt/dbus
[36mINFO[0m[0130] installing full qt/nfc
[36mINFO[0m[0131] installing full qt/script
[36mINFO[0m[0131] installing full qt/sensors
[36mINFO[0m[0132] installing full qt/positioning
[36mINFO[0m[0133] installing full qt/widgets
[36mINFO[0m[0134] installing full qt/sql
[36mINFO[0m[0135] installing full qt/qml
[36mINFO[0m[0136] installing full qt/websockets
[36mINFO[0m[0136] installing full qt/xmlpatterns
[36mINFO[0m[0137] installing full qt/bluetooth
[36mINFO[0m[0138] installing full qt/webchannel
[36mINFO[0m[0138] installing full qt/svg
[36mINFO[0m[0139] installing full qt/multimedia
[36mINFO[0m[0140] installing full qt/quick
[36mINFO[0m[0141] installing full qt/help
[36mINFO[0m[0141] installing full qt/location
[36mINFO[0m[0142] installing full qt/scripttools
[36mINFO[0m[0143] installing full qt/uitools
[36mINFO[0m[0144] installing full qt/winextras
github.com/therecipe/qt
github.com/therecipe/qt/winextras
# github.com/therecipe/qt/winextras
[36mINFO[0m[0151] installing full qt/testlib
[36mINFO[0m[0152] installing full qt/serialport
[36mINFO[0m[0152] installing full qt/serialbus
[36mINFO[0m[0153] installing full qt/printsupport
[36mINFO[0m[0154] installing full qt/designer
[36mINFO[0m[0155] installing full qt/scxml
[36mINFO[0m[0155] installing full qt/gamepad
[36mINFO[0m[0156] installing full qt/purchasing
[36mINFO[0m[0157] installing full qt/datavisualization
[36mINFO[0m[0157] installing full qt/charts
[36mINFO[0m[0158] installing full qt/speech
[36mINFO[0m[0159] installing full qt/quickcontrols2
[36mINFO[0m[0160] installing full qt/sailfish
[36mINFO[0m[0160] installing full qt/remoteobjects
[33mWARN[0m[0161] failed to install:
[33mWARN[0m[0161] winextras
 [36mINFO [0m[0953] running: 'qtsetup test windows' [docker=false] [vagrant=false]
 [36mINFO [0m[0953] testing widgets\line_edits
 [36mINFO [0m[1008] testing widgets\pixel_editor
 [36mINFO [0m[1054] testing widgets\textedit
 [36mINFO [0m[1225] testing qml\application
 [36mINFO [0m[1272] testing qml\drawer_nav_x
 [36mINFO [0m[1334] testing qml\gallery
 [36mINFO [0m[1384] testing quick\calc  

运行的测试代码所在目录源码目录(therecipe\qt)下的的internal\examples目录下。

 

6. 简单的程序

目录结构:

 

代码:


package main

import (
    "os"
    "github.com/therecipe/qt/widgets"
    "github.com/therecipe/qt/gui"
    "github.com/therecipe/qt/core"
)

func main() {
    // 创建应用程序
    app := widgets.NewQApplication(len(os.Args), os.Args)
    // 创建主窗口
    window := widgets.NewQWidget(nil, 0)
    // 设置窗口最小尺寸
    window.SetMinimumSize2(400, 200)
    // 设置标题
    window.SetWindowTitle("hello QT, hello GO")
    mainLayout := widgets.NewQVBoxLayout()
    // 创建垂直布局
    window.SetLayout(mainLayout)

    lineEidt := widgets.NewQLineEdit(nil)

    //创建一个label,用于存放go logo
    icon := gui.NewQPixmap5("go.jpg", "", core.Qt__AutoColor)
    iconLabel := widgets.NewQLabel(nil, 0)
    iconLabel.SetPixmap(icon)

    btn := widgets.NewQPushButton2("点我", nil)
    btn.ConnectClicked(func(bool) {
        widgets.QMessageBox_Information(nil, "我是对话框", "hello go,hello qt", widgets.QMessageBox__Ok, widgets.QMessageBox__Ok)
    })

    // !!!! 注意是AddWidget 不是AddChildWidget
    mainLayout.AddWidget(lineEidt, 0, 0)
    mainLayout.AddWidget(iconLabel, 0, 0)
    window.Layout().AddWidget(btn)

    // 显示窗口
    window.Show()
    // 进入消息循环
    app.Exec()
}  
main.go

生成目标exe文件


F:\Workspace\go\src\gui\qt>qtdeploy build desktop hello  

需要将go.jpg拷贝至hello\deploy\windows\目录下(与hello.exe处于一个目录下)方可正常运行。

运行效果

 

 遇到的问题:

1) "xxx/src/github.com/therecipe/qt/gui" has no buildable Go source files

 

 解决方法:

点击 Help > Edit Custom Properties


#添加如下内容
idea.max.intellisense.filesize=99999  

 

由于静态库gui.a很大,因此需要提高goland智能补全所允许的 单个文件大小上限

 

2) 运行时内存不足

 

解决方法:

点击Goland 的开始菜单  Help > Edit Custom VM Options

根据配置 修改-Xmx选项,例如:


-Xms512m
-Xmx4096m
-XX:ReservedCodeCacheSize=480m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow  

 -Xmx value limits the maximum heap memory size that the JVM can allocate.

参考:

https://github.com/therecipe/qt/wiki/Getting-Started

https://github.com/therecipe/qt/wiki/Installation-on-Windows

https://github.com/therecipe/qt/issues/90

https://stackoverflow.com/questions/23057988/file-size-exceeds-configured-limit-2560000-code-insight-features-not-availabl 

转载于:https://www.cnblogs.com/hupeng1234/p/9500827.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

windows下 go安装qt绑定 的相关文章

  • 使用加密 API 导入 DER 编码的公钥

    是否可以使用 MS crypto API 导入 DER 编码的公钥 那么我可以验证签名吗 我需要 MS Crypto API 的一段代码或帮助来导入 DER 编码的公钥 证书 以下三个步骤将允许您导入公钥证书 使用获取证书上下文证书创建证书
  • 如何在Windows中收集每个服务名称及其状态?

    我想在不使用任何第三方工具的情况下获取所有 service name 及其状态 迄今为止SC http ss64 com nt sc html命令足以获取其中一个值 例如 sc query findstr SERVICE NAME 但我还需
  • Windows下Kafka托管在Docker中删除主题时出现异常

    我在 Windows 的 Docker 中托管 Kafka 威斯迈斯特 卡夫卡 https hub docker com r wurstmeister kafka 使用 docker 镜像 Kafka 数据存储在本地 Windows 文件夹
  • 在 Jenkins 中执行批处理文件

    我有一个简单的批处理文件 我想要从 Jenkins 调用 运行 执行该文件 Jenkins 中有同样的插件吗 如何从 Jenkins 执行批处理文件 如果有相同的教程或文档 无需为此添加新插件 在Jenkins 选择您的工作名称并转到配置部
  • 在 Windows 上将 Mercurial (hg) 存储库转换为 Git (7)

    我现在真的很沮丧 我有一个现有的 hg 存储库 其中有几个月的编码历史 我想将其放入私有 Github 存储库中 以便我可以从那里对其进行处理 不幸的是我使用的是 Windows 我似乎找不到any转换我实际上可以正常工作的存储库的方法 实
  • Python 可执行文件:py2exe 还是 PyInstaller?

    要创建可执行文件 Windows 我假设我们应该使用其中之一 Py2exe 或 PyInstaller 它们之间有什么区别 Py2exe 和 PyInstaller 都是包装器 但我注意到以下几点差异 Py2exe 与 python2 4
  • R 脚本自动化时的不同结果

    以下命令对 pdf 文件执行 Ghostscript 这pdf file变量包含该 pdf 的路径 bbox lt system paste C gs gs8 64 bin gswin32c exe sDEVICE bbox dNOPAUS
  • RabbitMq 和“致命错误:握手失败 -handshake_decode_error”

    我正在使用 Windows Server 2012 Erlang 19 2 和 RabbitMq 3 6 6 我在使用 TLS 配置端点之间的连接时遇到问题 我已经尝试了所有关于 SO 的答案 以及所有 RabbitMq 文档here ht
  • 使用 IDLE 编辑的 .py 文件消失了

    我曾经有过Edit with IDLE当我右键单击时的选项 py文件 但我多次卸载 重新安装以使某些东西正常工作 但现在它消失了 我检查了注册表HKEY CLASSES ROOT and HKEY LOCAL MACHINE对于价值低于Py
  • 如何让脚本执行结束后自动删除?

    是否可以制作一个Python脚本 在Windows中执行结束时删除 py文件 自删除 这种方式使您的程序不依赖于操作系统 from os import remove from sys import argv remove argv 0 奖励
  • Python 无法在 git bash 命令行中工作

    Python 不会在 git bash Windows 中运行 当我在命令行中输入 python 时 它会将我带到一个空行 而不会像在 Powershell 中一样显示它已输入 python 2 7 10 它没有给我错误消息 但 pytho
  • .wav 文件长度/持续时间,无需读入文件

    有没有办法提取有关 wav 文件长度 持续时间的信息 而无需在 R 中读取文件 我有数千个这样的文件 如果我必须阅读每个文件才能找到其持续时间 那将需要很长时间 Windows 文件资源管理器为您提供了打开 长度 字段的选项 并且您可以查看
  • Windows Workflow Foundation 4 (WF4) 延迟

    我正在与 Visual Studio 2010 的候选版本一起使用 Wf4 编写一个用于批准资源请求的新工作流程 在我的工作流程中 如果请求未获得批准 我希望请求在几天后过期 我们在 WF 3 5 Visual Studio 2008 中通
  • 移动/调整窗口大小时闪烁

    我开发了一个显示 jpeg 图像的应用程序 它可以显示 4 个图像 屏幕的每个象限各一个 为此 它使用了 4 个窗口 窗口没有边框 框架 也没有标题栏 当加载新图像时 窗口大小会根据新图像进行调整 然后显示该图像 尤其是当窗户做得较大时 经
  • Kerberos 双跳

    我们遇到了臭名昭著的 Kerberos 双跳问题 这是一个全新的域 是从以前使用模拟和委派的另一个提供商迁移而来的 我们已将操作系统升级到最新的 SQL 服务器 2017 WPF 应用程序 使用域凭据 gt Web 服务 IIS 10 上的
  • 自定义波特率,redux

    我遇到的问题详述如下自定义波特率 https stackoverflow com questions 7714060 custom baud rate SetCommState 波特率 921600 失败 但波特率 115200 成功 尽管
  • 需要 TensorFlow 依赖项。如何在 Windows 上运行 TensorFlow

    我有兴趣让 TensorFlow 在 Windows 上运行 但目前我意识到这是不可能的 因为某些依赖项无法在 Windows 上使用 例如巴泽尔 之所以出现这种需求 是因为据我目前了解 从 TensorFlow 访问 GPU 的唯一方法是
  • 如何从Windows阻止社交媒体[关闭]

    Closed 这个问题需要调试细节 help minimal reproducible example 目前不接受答案 我想根据时间阻止我的电脑上的社交媒体 晚上 9 点后屏蔽 上午 11 点后解锁 如家长控制 我尝试过关注但失败了 创建了
  • Windows C++ 中的键盘钩子还是什么?

    我希望构建自己的应用程序 它可以将键盘命令 消息 发送到 Windows 操作系统 例如 当我按下组合键 ctrl shift n 时 我希望启动 notepad exe 我怎样才能做到这一点 您对所使用的概念有什么建议吗 我读过 何时使用
  • 如何查看网络连接状态是否发生变化?

    我正在编写一个应用程序 用于检查计算机是否连接到某个特定网络 并为我们的用户带来一些魔力 该应用程序将在后台运行并执行检查是否用户请求 托盘中的菜单 我还希望应用程序能够自动检查用户是否从有线更改为无线 或者断开连接并连接到新网络 并执行魔

随机推荐