Quote Originally Posted by Charletes View Post
What I am trying to do is implementing a plain text editor.
And what is wrong with QPlainTextEdit?

I need to use a QAbstractScrollArea instead of a QScrollArea because I want it to scroll lines instead of pixels when receiving a wheel event.
I don't see how QScrollArea is preventing you from doing that.

Moreover, I'd like to have in the viewport another widget which shows line numbers and, when receiving horizontal scroll events, scroll only the widget with the text but not the widget with the line numbers.
That's not how it's done. Use QAbstractScrollArea::setViewportMargins() and place your line counting widget in the blank space left by the viewport.