setContentsMargins() seems to not have any effect on QStackedLayout.

This code results in no margin:

Qt Code:
  1. mainLayout = new QStackedLayout(this);
  2. mainLayout->setContentsMargins(20, 20, 20, 20);
  3. mainLayout->addWidget(image);
  4. mainLayout->addWidget(text);
  5. mainLayout->setCurrentIndex(0);
To copy to clipboard, switch view to plain text mode 

while this has the correct 20 pixels margin

Qt Code:
  1. QVBoxLayout* mainLayout = new QVBoxLayout(this);
  2. mainLayout->setContentsMargins(20, 20, 20, 20);
  3. mainLayout->addWidget(image);
To copy to clipboard, switch view to plain text mode 

Any idea how I can have the margin on QStackedLayout?

Thanks