Hello,
I'm trying to achieve this in a QTextEdit.
http://bunjeee.free.fr/QTextEdit.png
Any idea ?
Printable View
Hello,
I'm trying to achieve this in a QTextEdit.
http://bunjeee.free.fr/QTextEdit.png
Any idea ?
http://doc.trolltech.com/4.3/qtexted...l#setAlignment
Compile and test this as an example:
Code:
#include <QApplication> #include <QtGui> int main(int argc, char* argv[]) { QTextEdit edit; edit.setText("blablabla"); edit.setAlignment(Qt::AlignRight); edit.show(); return app.exec(); }
Actually, there's a slight difference:
[html]
______________
| saddsadsa|
| asdds|
| dfds|
|_____________|
[/html]
vs.
[html]
______________
| saddsadsa|
| asdds |
| dfds |
|_____________|
[/html]
You can do the latter with the help of tables:
Code:
#include <QtGui> int main(int argc, char *argv[]) { QTextEdit edit; QTextTableFormat format; format.setAlignment(Qt::AlignRight); cursor.insertText("saddsadsa\nasdds\ndfds"); edit.show(); return a.exec(); }
Or use a horizontal layout with a spacer that will push your text edit widget to the right.
Man, that was tough.
I found absolutely no way to do it with a layout:
I needed a stretchable QParagraph with height for width justified on the right.
I had to reimplement my own widget to place it manually.
The layout wouldn't let me put a stretchable area that let the paragraph take as much space as it can.
Here is the result:
http://bunjeee.free.fr/alignedParagraph.png
Ask me if you need some code.
Regards.
But what exactly is your goal?
Hey Bunjee, i will need the code for QTextEdit align right:)