Sandip
19th November 2008, 07:29
Hi,
I have customized QGraphicsTextItem, added into scene.
I want to align the text in that item.
I tried following way but unable to get results.
Please help me.
alignment - is Qt::Alignment
QTextCursor objCursor = textCursor();
objCursor.movePosition(QTextCursor::Start);
objCursor.movePosition(QTextCursor::StartOfBlock);
QTextBlockFormat txtBlockFormat = objCursor.blockFormat();
txtBlockFormat.setAlignment(alignment);
objCursor.setBlockFormat(txtBlockFormat);
//or
objCursor.mergeBlockFormat(txtBlockFormat);
setTextCursor(objCursor);
The above code is supposed to align first block only.
I am expecting the results shown in attached image file.
Is there any other way to do it?
Thanks in advance.
Regards,
Sandip
I have customized QGraphicsTextItem, added into scene.
I want to align the text in that item.
I tried following way but unable to get results.
Please help me.
alignment - is Qt::Alignment
QTextCursor objCursor = textCursor();
objCursor.movePosition(QTextCursor::Start);
objCursor.movePosition(QTextCursor::StartOfBlock);
QTextBlockFormat txtBlockFormat = objCursor.blockFormat();
txtBlockFormat.setAlignment(alignment);
objCursor.setBlockFormat(txtBlockFormat);
//or
objCursor.mergeBlockFormat(txtBlockFormat);
setTextCursor(objCursor);
The above code is supposed to align first block only.
I am expecting the results shown in attached image file.
Is there any other way to do it?
Thanks in advance.
Regards,
Sandip