Results 1 to 5 of 5

Thread: QListView's scrollbar stylesheet

  1. #1
    Join Date
    May 2010
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QListView's scrollbar stylesheet

    Hi everyone,

    How to change the listview's scrollbar appearance?
    I have to change the background and up&down arrow of scrollbar.
    Example code will help me a lot. thanks.

  2. #2
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView's scrollbar stylesheet


  3. #3
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView's scrollbar stylesheet

    ListView->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal {border: 2px solid grey;background: #32CC99;height: 15px;margin: 0px 20px 0 20px;}");

  4. #4
    Join Date
    May 2010
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView's scrollbar stylesheet

    Quote Originally Posted by kemp View Post
    ListView->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal {border: 2px solid grey;background: #32CC99;height: 15px;margin: 0px 20px 0 20px;}");
    Thansk, it works.
    But the style is limited to change color, could not support image. The following code do not work as expect.
    ui->listView->verticalScrollBar()->setStyleSheet("QScrollBar:vertical {width: 15px; background-image: url(:/img/scroll_bg.png);}; QScrollBar::handle:vertical {image:url(:/img/scroll_handle.png)}");

  5. #5
    Join Date
    Aug 2006
    Posts
    77
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListView's scrollbar stylesheet

    You cannot support image for the QScrollBar with stylesheet. You can subclass the scrollbar and paint it yourself in the paintevent.

Similar Threads

  1. Using Scrollbar on mainwindow
    By Amit_3117 in forum Qt Programming
    Replies: 4
    Last Post: 30th October 2010, 06:09
  2. ScrollBar
    By damodharan in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2010, 15:50
  3. Scrollbar always grayed out
    By Gargolissimus in forum Newbie
    Replies: 5
    Last Post: 6th July 2009, 21:22
  4. QListView StyleSheet NOT WORKING!
    By QbelcorT in forum Qt Programming
    Replies: 5
    Last Post: 22nd March 2009, 09:38
  5. Scrollbar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2007, 08:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.