tags:

views:

52

answers:

2

Hi everybody,

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

A: 

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.

ak
no, i already tried it, but it doestn't work
sint
A: 

It works only fow QTextEdit, and nothing for QPlainTextEDit

sint