PDA

View Full Version : custom scroll bar for QTextEdit



ArkKup
19th March 2013, 14:09
Hi,

I'd like to create some custom scroll bar for my QTextEdit. I've found good hint to hide original scroll bar and create a bit of padding inside the QTextEdit for the custom QScrollBar
then in that area manually set QScrollBar.



QScrollBar *sBar = new QScrollBar();
edit->setStyleSheet("padding-right: 10");

but how do I set QScrollBar to the padded area ?

lanz
20th March 2013, 05:42
You don't need to add padding, simply call

edit->setVerticalScrollBar (sBar)
It will replace original scrollbar.
http://qt-project.org/doc/qt-4.8/qabstractscrollarea.html#setVerticalScrollBar

ArkKup
20th March 2013, 09:25
@ lanz:
this will not work for me since this scroll bar is dependent on QTextEdit and I need to have it independent from text, that's why I'd set new on in the padded area.

lanz
20th March 2013, 10:04
I see. Then I think you may create parent widget and add text edit with hidden scrollbar and your custom bar as its children.

Just out of curiosity, why are you need scrollbar that is independent from text edit?

ArkKup
20th March 2013, 10:14
Just out of curiosity, why are you need scrollbar that is independent from text edit?
I want to read a large text files and not to kill CPU so I need to load text in small chunks