开发者

Qt4 Designer Preview Resizing

开发者 https://www.devze.com 2023-03-20 07:57 出处:网络
I have a derived QDialog dialog layed out the way I want, and resizing the way I want, with the problem that the preview starts out resized to a larger size than it should.In designer, the window is s

I have a derived QDialog dialog layed out the way I want, and resizing the way I want, with the problem that the preview starts out resized to a larger size than it should. In designer, the window is shrunk to the smallest size possible given the policies and hints of everything contained, but in preview (and in real code I then assume) it grows larger than I want. I can then resize it down to its minimum size the way it looks in designer, but I'm wondering whe开发者_开发技巧re the extra space is coming from. Here're some pictures to illustrate, if that's not enough I can post the ui file or anything else.

Default preview size

Qt4 Designer Preview Resizing

Minimum preview size after resizing

Qt4 Designer Preview Resizing


Have you tried setting the vertical and horizontal size policy of the dialog to QSizePolicy::MinimumExpanding?


Call resize(0, 0) for your dialog widget after you have initialized the ui. That will set the widget to minimum size.

You are also using far too many spacers. I think all the vertical spacers except the leftmost one should be removed. Most of the horizontal spacers are also unnecessary.


@Roku, that didn't work either, and I did get rid of several spacers, but the others are all serving a purpose. I ended up just writing the UI by hand and it worked without a problem. I'm not sure what all the Designer adds to its source code that was borking my layout, I couldn't find any obvious offenders peeking through it.

This was my first real foray into using Designer, and while it's nice for quick mockups, it seems to be very brittle. Accidentally moving widgets or layouts around breaks all the size policies you've set up, for instance, even after undos. And in the end, it didn't take me much longer to do it by hand than to use Designer, and you don't have to put up with the messy hassle of integrating it into your code or trying to track down unexpected behavior. So -1 for Designer here.

Here's how it came out http://i.stack.imgur.com/UVrFG.png

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号