PDA

View Full Version : QTExtEdit->setAlignment ( int a ) doesnt work with setWrapPolicy ( QTextEdit::Anywher



vermarajeev
15th February 2007, 06:10
Hi guys,
I have a textEdit and I have set the wrapPolicy to Anywhere, Now If I'm trying to
Align the text to Right, or Left or Center, the text doesn't get aligned. Is this a bug in QTextEdit (Qt3.3.5) or Is there something that I'm doing wrong.

Here is the code snippet


void TextEdit::textAlign( QAction *a )
{
if ( !currentEditor() )
return;

currentEditor()->setWrapPolicy( QTextEdit::Anywhere ); //If I remove this
//the text gets aligned

if ( a == actionAlignLeft )
currentEditor()->setAlignment( AlignLeft );
else if ( a == actionAlignCenter )
currentEditor()->setAlignment( AlignHCenter );
else if ( a == actionAlignRight )
currentEditor()->setAlignment( AlignRight );
else if ( a == actionAlignJustify )
currentEditor()->setAlignment( AlignJustify );
}

The snippet is a copy of Qt/3.3.5/examples/textedit.

Please help to rectify this problem

vermarajeev
16th February 2007, 08:22
Hi guys,
I have a textEdit and I have set the wrapPolicy to Anywhere, Now If I'm trying to
Align the text to Right, or Left or Center, the text doesn't get aligned. Is this a bug in QTextEdit (Qt3.3.5) or Is there something that I'm doing wrong.

Here is the code snippet


void TextEdit::textAlign( QAction *a )
{
if ( !currentEditor() )
return;

currentEditor()->setWrapPolicy( QTextEdit::Anywhere ); //If I remove this
//the text gets aligned

if ( a == actionAlignLeft )
currentEditor()->setAlignment( AlignLeft );
else if ( a == actionAlignCenter )
currentEditor()->setAlignment( AlignHCenter );
else if ( a == actionAlignRight )
currentEditor()->setAlignment( AlignRight );
else if ( a == actionAlignJustify )
currentEditor()->setAlignment( AlignJustify );
}

The snippet is a copy of Qt/3.3.5/examples/textedit.

Please help to rectify this problem

Is there any way out????
Please help....