1

how can i set different margins for each QTextBlock in QTextEdit/QPlainTextEdit?

i tried to set it with following code:

class MyWidget(QPlainTextEdit):

    def func(self):
        block = self.firstVisibleBlock()
        while block.isValid():
            block = block.next()
            block.blockFormat().setLeftMargin(<some_value>)

but it's not working

Thanks

1
  • Margin means what? you mean width? or what? Commented Apr 22, 2010 at 6:40

2 Answers 2

1

Try exploring the docs: http://doc.trolltech.com/4.5/qtextblockformat.html If you have your QTextBlock, then you could use something like this:

QTextBlock *block = ...;
block->blockFormat()->set[Left|Right|Top|Bottom]Margin(qreal margin);

Please let us know if it works, as I have not tried this code.

Sign up to request clarification or add additional context in comments.

Comments

1

It works only fow QTextEdit, and nothing for QPlainTextEDit

2 Comments

Any refs to back that up? It would explain a lot, but would be nice to have this documented somewhere ...
@Almar The closest statement I could find is this, with the quote from the Qt docs coming from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.