RemoveItem() Stretch 和 Spacing 都属于 QSpacerItem 使用removeItem 删除: for (int i = 0; i < boxLayout->count(); ++i) { QLayoutItem *layoutItem = boxLayout->itemAt(i); if(layoutItem->spacerItem()) { boxLayout->removeItem(layoutItem); i--; } }