如何在 Qt 设计器中使控件自动调整大小?
我正在将 Qt Jambi 4.4 用于我正在从事的项目(并在 Qt Designer eclipse 插件中设计窗口)。 我想使用的窗口之一是预览窗口,它基本上只是一个带有 QWebView 的窗口。 我怎样才能使 QWebView 随窗口调整大小? 我已将 sizePolicy 设置为水平和垂直位置的扩展。 我还需要做什么?
(还要记住,我是 Java 和 Eclipse 的新手,需要用愚蠢的人的术语来谈论这两个主题)
更新
只是为了说明这一点,这里有几个屏幕截图(我将窗口背景设置为明亮只是为了说明我的观点):
alt text http://img13.imageshack.us/img13/2103/screenshot2oi7.jpg
替代文本http://img152.imageshack.us/img152/6250/screenshot1mz9.jpg
I'm using Qt Jambi 4.4 for a project I'm working on (and designing the windows in the Qt Designer eclipse plugin). One of the windows I'd like to use is a preview window which is basically just a window with a QWebView on it. How can I make it so that the QWebView resizes as the window does? I've set the sizePolicy to expanding for both Horizontal and Vertical position. What else do I need to do?
(also bear in mind that I'm a newbie to both Java and eclipse and need to be talked to in stupid people terms on both of those subjects)
UPDATE
Just to illustrate the point, here are a couple of screenshots (I've made the window background bright just to illustrate my point):
alt text http://img13.imageshack.us/img13/2103/screenshot2oi7.jpg
alt text http://img152.imageshack.us/img152/6250/screenshot1mz9.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将 QWebView 放置在布局中,它将跟随其“容器”中的更改。 有关在 Qt Designer 中使用布局的信息,请参阅 http://doc.trolltech.com/4.5 /designer-layouts.html
You need to place the QWebView in a layout, that it will follow the change in its "container". For using layout with Qt Designer, refer to http://doc.trolltech.com/4.5/designer-layouts.html
来自 Qt Designer 文档:
From Qt Designer docs:
我不知道 Jambi,但使用 Qt Designer 只需将焦点放在背景上,然后从工具栏中应用布局即可。 然后,主小部件将由该布局管理器调整大小 - 如果您不添加该布局管理器,您将调整小部件的大小,但内容仍保留在原来的位置。
I don't know Jambi, but with Qt Designer just give the background the focus and then apply a layout from the toolbar. Then the main widget will get resized by that layout manager -- if you don't add that layout manager you'll get the widget resizing but the contents staying at their old positions.
我没有使用过 qt-jambi,但如果它是类似 C++ 中的 Qt 或 PyQt 的东西,QWebView 会随着窗口大小的变化自动调整大小。 据我所知,只有当大小调整行为无法正常工作时,才需要设置大小策略/扩展因子、添加 QSpacerItem 对象等。 只需在预览窗口中使用适当的布局进行布局就足够了。 如果我误解了这个问题,请告诉我。
I haven't used qt-jambi, but if it is anything like Qt in C++ or PyQt, the QWebView would resize automatically as the window size changes. As far as I know, setting size policies/ expansion factors, adding QSpacerItem objects etc. is only necessary if the sizing behavior is not working right. Just laying it out using an appropriate layout within the preview window should be sufficient. Do let me know if I have misunderstood the question.