Results 1 to 5 of 5

Thread: custom scroll bar for QTextEdit

  1. #1
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14

    Default custom scroll bar for QTextEdit

    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.

    Qt Code:
    1. QScrollBar *sBar = new QScrollBar();
    2. edit->setStyleSheet("padding-right: 10");
    To copy to clipboard, switch view to plain text mode 
    but how do I set QScrollBar to the padded area ?
    Last edited by ArkKup; 19th March 2013 at 15:54.

  2. #2
    Join Date
    Dec 2012
    Posts
    90
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 20 Times in 18 Posts

    Default Re: custom scroll bar for QTextEdit

    You don't need to add padding, simply call
    Qt Code:
    1. edit->setVerticalScrollBar (sBar)
    To copy to clipboard, switch view to plain text mode 
    It will replace original scrollbar.
    http://qt-project.org/doc/qt-4.8/qab...ticalScrollBar

  3. #3
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14

    Default Re: custom scroll bar for QTextEdit

    @ 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.

  4. #4
    Join Date
    Dec 2012
    Posts
    90
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 20 Times in 18 Posts

    Default Re: custom scroll bar for QTextEdit

    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?

  5. #5
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    14

    Default Re: custom scroll bar for QTextEdit

    Quote Originally Posted by lanz View Post
    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

Similar Threads

  1. Replies: 2
    Last Post: 9th July 2012, 06:26
  2. How to detect scroll on QtextEdit
    By tonnot in forum Newbie
    Replies: 1
    Last Post: 10th October 2011, 22:15
  3. hangup vertical scroll bar in qtextedit
    By mero in forum Qt Programming
    Replies: 1
    Last Post: 19th February 2011, 19:59
  4. QTextedit scroll or paint problem
    By pavanbarot in forum Qt Programming
    Replies: 0
    Last Post: 29th December 2010, 14:22
  5. QTextEdit + auto scroll
    By jbpvr in forum Qt Programming
    Replies: 7
    Last Post: 25th March 2008, 10:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.