在 Qt 中强制调整小部件大小
我正在编写一个图像查看器,我想要 Qt 的一些行为:
想象查看器在 256x256 框中显示图像。现在我希望 ctrl+Z 对窗口进行缩放+调整大小; IE。在 512x512 框中显示 2 倍缩放图像,我该怎么做?
另外,假设知道用户为我的查看器提供了某种形状,并且他按了 F10,我想更改布局以以相同的大小显示查看器(如果可能,例如不溢出屏幕)并在其下添加其他控件,并以查看器小部件的方式调整整个小部件的大小
I'm writing an image viewer, and I'd like some behavior from Qt:
imagine the viewer displays the image in a 256x256 box. Now I want that ctrl+Z do a zoom + resizing of the window; ie. show the 2x zoomed image in a 512x512 box, how can I do that?
Also, imagine know the user gave a certain shape to my viewer, and that he presses F10, I want to change the layout to display the viewer in the same size (if possible, eg not overflowing the screen) and add additional controls under it, and resize the complete widget in a way that the viewer widget does
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以使用 QWidget::minimumSize 属性来更改小部件最小尺寸。
如果缩放图像的尺寸大于屏幕,您可能必须将小部件放入 QScrollArea.
Maybe you could use the QWidget::minimumSize property to change the widget minimal size.
If the size of your zoomed image gets bigger than the screen, you might have to put your widget into a QScrollArea.