Qt widget (with layout) space. What is it? How to remove?

前端 未结 3 779
逝去的感伤
逝去的感伤 2020-12-11 21:09

I have written a program that uses widgets as container (for other widgets). Because the contents of the container varies along the program life, the container widget has a

相关标签:
3条回答
  • 2020-12-11 21:15

    The space you referring to is a content margin. The docu here describes how the widgets are drawn. To get rid of that extra space you have to call:

    widget->setContentsMargins(0, 0, 0, 0);
    

    I believe the end result should look like this:

    enter image description here

    0 讨论(0)
  • 2020-12-11 21:22

    The method I recall to control spacing is to add dedicated QSpacerItem items between the widgets.

    But I'm first trying to figure out what w is doing. Why not call g1a_l->addLayout(t); directly?

    0 讨论(0)
  • 2020-12-11 21:32

    This is contentsMargin

    To remove it:

    t->setContentsMargins(0,0,0,0);
    
    0 讨论(0)
提交回复
热议问题