Qt Creator - 如何编写 UI?
我是 Qt 的初学者,我发现 Qt 中内置的大多数小部件都没有出现在小部件工具箱中。
如何将所有小部件添加到工具箱? (就像默认情况下不会出现在工具箱中的
QSystemTrayIcon
)编写 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.
How can I add all the widget to tool box? (Like
QSystemTrayIcon
that does not appear by default in tool box)what is the best way to write gui - by the designer - ui file or by code - cpp file?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设计器仅显示窗口中显示的小部件。在窗口设计工具中“设计”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...
我建议不要使用设计器,以便使用纯 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.