PDA

View Full Version : Is it possible to set a fixed margin for a QTextEdit?



Ahas
5th February 2009, 14:13
Is it possible to set a fixed margin for a QTextEdit so that all loaded html respect the margin even if there is no margin in in the loaded html?

Cruz
5th February 2009, 14:34
Have you tried setting a style sheet yet?



textEdit->setStyleSheet("margin: 5px");


See Qt Style Sheets (http://doc.trolltech.com/4.4/stylesheet.html)

Ahas
5th February 2009, 15:22
Thanks, that works.

I didn't know you could apply stylesheets to widgets, and I couldn't find a way to do it in the class reference of QTextEdit.

But I need to use padding, not margin. Margin seems to set the distance to other widgets not to the text in the textEdit.

Cruz
5th February 2009, 15:32
If you follow the link above, you will find the "box model" which explains what's margin and padding and what not. If you do use style sheets, you might want to consider placing the style sheet definitions in an external file, so that they are centered in one place and easily modifiable without even having to recompile.