hi freinds,

I use a QTextEdit in my app, and want it to support both rtl & ltr text directions, while having ability to change alignment, independent of the text direction.

I wrote these slots for setting alignment:
Qt Code:
  1. void MyEditor::sltAlignRight()
  2. {
  3. editor->setAlignment(Qt::AlignRight);
  4. editor->setFocus(Qt::OtherFocusReason);
  5. }
  6.  
  7. void MyEditor::sltAlignLeft()
  8. {
  9. editor->setAlignment(Qt::AlignLeft);
  10. editor->setFocus(Qt::OtherFocusReason);
  11. }
To copy to clipboard, switch view to plain text mode 

and this one for changing text direction:
Qt Code:
  1. void MyEditor::sltChangeLayoutDirection()
  2. {
  3. QTextBlockFormat f = editor->textCursor().blockFormat();
  4.  
  5. if (f.layoutDirection() != Qt::RightToLeft) {
  6. f.setLayoutDirection(Qt::RightToLeft);
  7. } else {
  8. f.setLayoutDirection(Qt::LeftToRight);
  9. }
  10. editor->textCursor().mergeBlockFormat(f);
  11.  
  12. editor->setFocus(Qt::OtherFocusReason);
  13. }
To copy to clipboard, switch view to plain text mode 

the problem is, when sltChangeLayoutDirection() is triggered, to make the text right-to-left, direction changes successfully, but editor content is aligned at right side.
but editor->alignment() returns Qt::AlignLeft.
now, if I call sltAlignRight(), editor content will be aligned at left side!

I wonder if this is my fault in coding, or it's really a bug of QTextEdit?
Did anyone have the same problem?

I use ubuntu8.04 with kde4.1.
thanks a lot.