From f0a8999a6c2cc9ea3894752dfb5d06be5058461b Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 2 Sep 2026 08:53:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(vqt6):=20=E6=96=B0=E5=A2=9E=20ViperQtProje?= =?UTF-8?q?ct=20Qt6=20Hello=20World=20=E6=B5=8B=E8=AF=95=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - project.vpj: 静态链接 libvqt6_bridge.a,链接 Qt6.11.2 MinGW 动态库(Core/Gui/Widgets/Network) - App/main.vp: QApplication + QWidget + QLabel + QPushButton 测试,FFI 摆放子控件几何 --- ViperQtProject/App/main.vp | 33 ++++++++++++++++++++++ ViperQtProject/project.vpj | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 ViperQtProject/App/main.vp create mode 100644 ViperQtProject/project.vpj diff --git a/ViperQtProject/App/main.vp b/ViperQtProject/App/main.vp new file mode 100644 index 0000000..ed3ba4e --- /dev/null +++ b/ViperQtProject/App/main.vp @@ -0,0 +1,33 @@ +# main.vp — ViperQtProject:vqt6 Qt6 GUI Hello World 测试 +# +# 构建需 project.vpj: +# - 静态链接 ../includes/vqt6/build/lib/libvqt6_bridge.a +# - 链接 Qt6 动态库(-L D:/Qt/6.11.2/mingw_64/lib -lQt6Core/Gui/Widgets/Network) +# +# 注意: +# - QApplication(argv) 的 argv 被包装层忽略(桥接层提供虚拟 argv), +# 这里传 t.CPtr(0)(null 指针)即可(TPV 不支持列表字面量)。 +# - 高层包装 QLabel/QPushButton 未提供 move/setGeometry,直接调 FFI 摆放几何。 +import t +import vqt6 + + +def main() -> int: + # 1. QApplication(argv 被忽略,桥接层提供虚拟 argv) + app = vqt6.QApplication(t.CPtr(0)) + + # 2. 主窗口 + win = vqt6.QWidget() + win.setWindowTitle("Viper Qt6 Demo") + win.resize(640, 480) + + # 3. 子控件(直接调 FFI 设置几何位置) + label = vqt6.QLabel("Hello from Viper + Qt6!", win) + vqt6.vqt6_qwidget_set_geometry(label._ptr, 20, 20, 400, 40) + + btn = vqt6.QPushButton("Click Me", win) + vqt6.vqt6_qwidget_set_geometry(btn._ptr, 20, 70, 120, 36) + + # 4. 显示并进入事件循环 + win.show() + return app.exec() diff --git a/ViperQtProject/project.vpj b/ViperQtProject/project.vpj new file mode 100644 index 0000000..90d90d5 --- /dev/null +++ b/ViperQtProject/project.vpj @@ -0,0 +1,56 @@ +{ + "name": "ViperQtProject - Qt6 GUI Test", + "version": "1.0.0", + "source_dir": "./App", + "build_dir": "./.tpv_build", + "compiler": { + "cmd": "llc", + "flags": [ + "-filetype=obj", + "-relocation-model=pic" + ] + }, + "linker": { + "cmd": "clang++", + "flags": [ + "-lmsvcrt", + "-lucrt", + "-lpthread", + "-lmingwex", + "-lkernel32", + "-Wl,--allow-multiple-definition", + "-lcomdlg32", + "-lcomctl32", + "-lole32", + "-luuid", + "-lwinmm", + "-lgdi32", + "-lgdiplus", + "-ladvapi32", + "-lshell32", + "-lws2_32", + "-luser32", + "-L D:/Qt/6.11.2/mingw_64/lib", + "-lQt6Core", + "-lQt6Gui", + "-lQt6Widgets", + "-lQt6Network" + ], + "static_libs": [ + "../includes/vqt6/build/lib/libvqt6_bridge.a" + ], + "output": "app.exe" + }, + "includes": [ + "../includes" + ], + "target": { + "triple": "x86_64-pc-windows-gnu", + "datalayout": "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + }, + "options": { + "slice_level": 3, + "target": "llvm", + "strict_mode": true + } +}