• 5967阅读
  • 3回复

[提问]这个间隙怎么产生的? [复制链接]

上一主题 下一主题
离线justwake
 

只看楼主 倒序阅读 楼主  发表于: 2013-01-07
先上图再说:

重载了标题栏  就是哪个黑色的条条!
问题就是红色箭头指的位置,有间隙,也就是标题栏和边有间隙,
但是后面那个窗口没有,后面那个窗口是designer设计的ui  我在上面拉出一个到边的widget,然后在代码中把标题栏放进去!
前面这个窗口  是纯代码生成的!可是不到边。
我查看了ui生成的文件,里面也只是设置setGeometry,我前面这个窗口也设置了,而且widget的固定宽度和标题栏的固定宽度相同,
可是不知道为什么会产生那个间隙?

希望大牛指点下,给个提示!
离线jdwx

只看该作者 1楼 发表于: 2013-01-07
回 楼主(justwake) 的帖子
找到最外层的layout

layout->setContentsMargins(0,0,0,0);
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
离线kimtaikee

只看该作者 2楼 发表于: 2013-01-07
void QLayout::setContentsMargins ( int left, int top, int right, int bottom )
Sets the left, top, right, and bottom margins to use around the layout.

By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions.

This function was introduced in Qt 4.3.

See also contentsMargins(), getContentsMargins(), QStyle::pixelMetric(), PM_LayoutLeftMargin, PM_LayoutTopMargin, PM_LayoutRightMargin, and PM_LayoutBottomMargin.

离线justwake

只看该作者 3楼 发表于: 2013-01-08
非常感谢楼上两位大大,已经解决!!!
快速回复
限100 字节
 
上一个 下一个