Qt 写的程序,可以通过某些方式,在 web 上浏览

​www.youtube.com

你也可以自己跑以下demo

​msorvig.github.io


主要有2种方式,一个借助 WebAssembly,一个借助WebGL

我们先说后一种,因为这个比较简单

首先你程序必须是基于 Qt Quick 的,比如名叫 MyApp

然后编译完后,通过 ./MyApp -platform webgl:port=8998

就可以通过打开浏览器,输入 127.0.0.1:8998 来访问你的程序了

这种方式有一个缺点,一次只能跑一个实例

 

第二种方式是webAssembly

详细的安装和使用可以参考这篇文章

主要讲讲我安装编译遇到的一些问题

首先是执行 ./emsdk install latest的时候出错,因为在公司需要设置代理

export https://………………

然后修改./emsdk下的emsdk,用gedit打开后,在第12行新增import ssl

在18行新增ssl._create_default_https_context = ssl._create_unverified_context

 

接着在 ./qt-everywhere-src-5.12.0/configure -xplatform wasm-emscripten -nomake examples -prefix $PWD/qtbase时报错,提示

Project ERROR: You cannot configure qt separately within a top-level build.

解决方法:删除主目录下的隐藏文件.qmake.super (我后来把.qmake开头的都删了 >o<)

 

接下来又报错

ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.

Check config.log for details.

解决方法:查看config.log发现urllib2.URLError: <urlopen error Tunnel connection failed: 407 authenticationrequired>

先export https://账号:密码@代理服务器:端口号

再在emsdk/emscripten/1.38.21/tools/ports/zlib.py添加

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

接着多等待一段时间,makefile就建立好了

 https://zhuanlan.zhihu.com/p/51694632

相关文章:

  • 2021-09-07
  • 2021-05-27
  • 2021-04-20
  • 2022-12-23
  • 2021-08-12
  • 2022-02-10
  • 2022-12-23
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案