QTextFrame* rootFrame = textBrowser->document()->rootFrame();
QTextFrameFormat rootFrameFormat = rootFrame->frameFormat();
rootFrameFormat.setLeftMargin(16);
rootFrameFormat.setRightMargin(16);
rootFrameFormat.setTopMargin(8);
rootFrameFormat.setBottomMargin(8);
rootFrame->setFrameFormat(rootFrameFormat);
使用textFrameFormat可以避免像直接用qss设置padding导致滚动条也产生边距等问题
类似的情况还出现在其他继承自QAbstractScrollArea的控件中,设置qss边距等应设置在内部viewport上,viewport不包含滚动条。