QHBoxLayout * horizontalLayout = new QHBoxLayout; //setContentsMargins(int left, int top, int right, int bottom) //设置上下左右的边距分别为0 horizontalLayout->setContentsMargins(0, 0, 0, 0);