1

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 where 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

enter image description here

Minimum preview size after resizing

enter image description here

4

3 回答 3

0

您是否尝试将对话框的垂直和水平大小策略设置为QSizePolicy::MinimumExpanding

于 2011-07-12T23:36:37.557 回答
0

@Roku,那也不起作用,我确实摆脱了几个垫片,但其他垫片都是有目的的。我最终只是手工编写了 UI,它没有任何问题。我不确定设计师在其源代码中添加的所有内容是否会破坏我的布局,我找不到任何明显的违规者偷看它。

这是我第一次真正尝试使用 Designer,虽然它很适合快速制作模型,但它似乎非常脆弱。意外移动小部件或布局会破坏您设置的所有大小策略,例如,即使在撤消之后也是如此。最后,与使用 Designer 相比,手动完成并没有花费我多长时间,而且您不必忍受将其集成到代码中或尝试追踪意外行为的麻烦。所以这里的设计师是-1。

这是它的结果 http://i.stack.imgur.com/UVrFG.png

于 2011-07-13T20:13:55.637 回答
0

resize(0, 0)初始化 ui 后调用对话框小部件。这会将小部件设置为最小尺寸。

您还使用了太多的垫片。我认为除了最左边的一个之外,所有的垂直间隔都应该被移除。大多数水平垫片也是不必要的。

于 2011-07-13T08:26:21.343 回答