Qt Creator - 如何编写 UI?

发布于 2024-09-28 18:05:47 字数 218 浏览 0 评论 0原文

我是 Qt 的初学者,我发现 Qt 中内置的大多数小部件都没有出现在小部件工具箱中。

  1. 如何将所有小部件添加到工具箱? (就像默认情况下不会出现在工具箱中的QSystemTrayIcon

  2. 编写 gui 的最佳方式是什么 - 由设计者 - ui 文件还是通过代码 - cpp 文件?

谢谢!

I'm beginner to Qt and I see that most of widgets that are build in in Qt do not appear in the widgets tool box.

  1. How can I add all the widget to tool box? (Like QSystemTrayIcon that does not appear by default in tool box)

  2. what is the best way to write gui - by the designer - ui file or by code - cpp file?

Thanks!

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

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

发布评论

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

评论(2

梦中楼上月下 2024-10-05 18:05:47

设计器仅显示窗口中显示的小部件。在窗口设计工具中“设计”QSystemTrayIcon 是没有意义的。只需在启动期间从代码创建它即可。

您是手动编写 UI 代码还是使用设计器完全取决于您。就我而言,我认为 Qt 的设计器是一个非常成熟的工具,可以帮助我快速设计用户界面。所以是的,我用它......

The designer just shows widgets which are displayed in a window. It doesn't make sense to 'design' a QSystemTrayIcon in a window design tool. Just create it from code during startup.

Wether you write the UI code by hand or use the designer is really up to you. Speaking of me, I consider Qt's designer a very mature tool that helps designing my user interfaces quickly. So yes, I use it...

長街聽風 2024-10-05 18:05:47

我建议不要使用设计器,以便使用纯 C++ 代码并且不处理某些 qt 代码生成。在我看来,这是一种灵活的方法,但我猜,很多人都使用 Qt 设计器,甚至喜欢它。所以这是个人的事情。但是,说实话,我在初学者时就使用过 Qt 设计器。使用可视化编辑器配置小部件对我来说有很大帮助。不,我更喜欢只编码。

WRT 添加您列出的小部件 - 不,这是不可能的。您应该手动实例化它们。

I would advice to not use designer, in order to work with a pure c++ code and do not deal with some qt code generations. It is flexible approach in my opinion, though, I guess, lot of people use Qt designer, and even like it. So this is something personal. But, honestly, I used Qt designer when I was a beginner. Configuring widgets with a visual editor was a great help for me. No I prefer only coding.

WRT adding the widgets you listed - no it is not possible. You should instantiate them manually.

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