How to place a QTextEdit
with left and right margins in a QVBoxLayout
? I could use, of course, a QHBoxLayout
, place the QTextEdit
into that horizontal layout in between to spacings (addSpacing(40)
) and only then the horizontal layout could add into the vertical layout, but want to know if there is a direct way of doing that.
If you want the margins only for your QTextEdit and not any other element in the QVerticalLayout you can use QT stylesheets for that. You just need to give a name to the QTextEdit object (like "myMarginsTextEdit") and style it, eg:
QTextEdit#myMarginsTextEdit
{
margin-left: 40px;
margin-right: 40px;
}
If you are not using QT stylesheets to style your application you can still use it only to style that item. You can do it like this (imagine your QTextEdit variable is call "textEditItem"):
textEditItem.setStyleSheet("QTextEdit {margin-left:40px; margin-right:40px}");
The other option is use content margins in the vertical layout but then it is applied to all elements.