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 + } +}