Qt:使用 Qt 脚本添加 UI 元素

发布于 2024-07-27 23:56:56 字数 153 浏览 6 评论 0原文

是否可以使用 QtScript 将新的 GUI 元素添加到 Qt 程序中? 例如,假设变量“布局”是垂直布局,这可以接受吗?

var label = new QLabel("Text");
layout.addWidget(label);

Is it possible to add new GUI elements into a Qt program using QtScript? For instance assuming the variable "layout" is a vertical layout would this be acceptable?

var label = new QLabel("Text");
layout.addWidget(label);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋 2024-08-03 23:56:56

Qt 不附带 QtScript 绑定; 您使用哪些绑定?

如果您在 Qt Labs 上使用绑定生成器,是的,假设您已安排将“布局”变量导入到脚本引擎中,则此代码可以正常工作。

Qt doesn't ship with QtScript bindings; which bindings are you using?

If you're using the bindings generator on Qt Labs, yes, this code would work fine, assuming you arranged for the `layout' variable to be imported into your script engine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文