PDA

View Full Version : Setting up wordwrap in a QTextDocument



lxman
12th March 2011, 06:04
This is my current attempt:


MyQTextEdit::MyQTextEdit(QRect init_rect, QWidget *parent) :
QTextEdit(parent)
{
my_scene_rect = init_rect;
QTextOption to;
to.setWrapMode(QTextOption::WordWrap);
doc.setDefaultTextOption(to);
this->setDocument(&doc);
this->setObjectName("TextEdit");
this->setMouseTracking(true);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setReadOnly(true);
this->viewport()->setCursor(Qt::ArrowCursor);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
this->setWordWrapMode(QTextOption::WordWrap);
this->setLineWrapMode(QTextEdit::WidgetWidth);
follow_mouse = false;
resizing = false;
rotating = false;
mouse_pos.clear();
}



I want the scroll bars off and word wrap on. The scroll bars are staying off, but when the text reaches the right edge of the widget, it does not wrap. It just continues off past the right edge.

Any ideas?