The margins are indeed drawn by the scroll area and to paint anything on them it is highly recommened to use a custom layout. Custom is important here because it implies using setViewportMargins() from the layout (actually a public wrapper function but it does not make such a difference).
tQPainter MUST be initialized on viewport()!!! Indeed (nearly) *ALL* events recieved by a QAbstractScrollArea are redirected from its viewport... Besides it is generally a bad idea to draw the margins from the widget paint event... You should consider placing this code in another widget which would be parented to the editor and managed by the aforementioned custom layout. FYI I made such a custom layout, inspired of Qt 4 Border Layout example, for use with the next version of QCodeEdit.
Also I hope you consider me as a little more than "something"...![]()
Bookmarks