You can easily add horizontal scroll bar in the QPlainTextEdit
Widget by setting the line wrap property, your code should be:
QPlainTextEdit * editor = new QPlainTextEdit(this);
editor->setLineWrapMode(QPlainTextEdit::NoWrap);
setCentralWidget(editor);
QPlainTextEdit::NoWrap
mode will automatically add the horizontal scroll bar when the line width exceed the editor width.