美文网首页
Qt中使用setSpacing仍然有间隙的问题

Qt中使用setSpacing仍然有间隙的问题

作者: _compass | 来源:发表于2020-08-06 16:05 被阅读0次

在Qt中,使用了 QVBoxLayout,设置Space为0,ContentsMargins也为0,但是仍然各个方向有11像素的空白。


1.png

以下代码是设置setSpacing,setContentsMargins,setMargin都无效。

  // 以下代码无效
  QVBoxLayout* tMainVB = new QVBoxLayout;
  tMainVB->setSpacing(0);
  tMainVB->setContentsMargins(0,0,0,0);
  this->setLayout(tMainVB);

后来发现使用了insertSpacing是可以的:


2.png
  QVBoxLayout* tMainVB = new QVBoxLayout;
  tMainVB->setSpacing(0);
  tMainVB->setContentsMargins(0,0,0,0);
  tMainVB->insertSpacing(0, -12);
  this->setLayout(tMainVB);

以上。

相关文章

网友评论

      本文标题:Qt中使用setSpacing仍然有间隙的问题

      本文链接:https://www.haomeiwen.com/subject/hzttdktx.html