PDA

View Full Version : Code editor display the line number in an area to the right



Ramang
19th January 2016, 16:00
I am just learning Qt. I want to show line number of QPlainTextEdit. I found this link http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html
and it worked. But now I want the editor displays the line numbers in an area to the RIGHTof the area for editing. I have been search google very much but i can't solve. How to solve? Thank you very much
[1]: http://i.stack.imgur.com/x4AKi.png

Ginsengelf
19th January 2016, 16:09
Hi, you can use the example and move the line number area to the right side. You just have to move some parameters in functions that define the position and size of the line number widget, e.g. CodeEditor::updateLineNumberAreaWidth()

Best regards,

Ginsengelf

Ramang
20th January 2016, 01:40
Thank for your reply.
I changed
CodeEditor::updateLineNumberAreaWidth(){
setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
}
but I cant't solve. I don't know which parameters have to move. Thank!