Results 1 to 2 of 2

Thread: Customising the scroll bar in a QListWidget

  1. #1

    Default Customising the scroll bar in a QListWidget

    Hi all,

    I seem to have a problem in customizing the scroll bar in the QListWidget. Please advise on where i am going wrong.

    //////////////////////////////////////////////////////////////////////////////

    QString css_string = "vertical {
    border: 2px solid grey;
    background: #32CC99;
    height: 15px;
    margin: 0px 20px 0 20px;}
    handle:vertical {
    background: white;
    min-width: 20px;}
    add-line:vertical {
    border: 2px solid grey;
    background: #32CC99;
    width: 20px;
    subcontrol-position: right;
    subcontrol-origin: margin;}
    sub-line:vertical {
    border: 2px solid grey;
    background: #32CC99;
    width: 20px;
    subcontrol-position: left;
    subcontrol-origin: margin; }";

    mainmenu::mainmenu()
    {
    ui_mainmenu.setupUi(this);
    setWindowFlags( Qt::CustomizeWindowHint);

    connect(ui_mainmenu.listWidget, SIGNAL(itemClicked(QListWidgetItem *)),
    this, SLOT(touchList()));

    QScrollBar *vbar = ui_mainmenu.listWidget->verticalScrollBar();
    vbar->setStyleSheet(css_string);
    }


    //////////////////////////////////////////////////////////////////////////////

    The applied style sheet doesnot appear on my application. Is there a better way to customize the scroll bar in the list widget.

    Thanks in advance,
    B

  2. #2
    Join Date
    Nov 2010
    Posts
    57
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Customising the scroll bar in a QListWidget

    First thing I notice is
    Qt Code:
    1. vertical {
    2. border: 2px solid grey;
    3. background: #32CC99;
    4. height: 15px;
    5. margin: 0px 20px 0 20px;}
    To copy to clipboard, switch view to plain text mode 

    Should be:
    Qt Code:
    1. vertical {
    2. border: 2px solid grey;
    3. background: #32CC99;
    4. width: 15px;
    5. margin: 20px 0px 20px 0px ;}
    To copy to clipboard, switch view to plain text mode 

    Something like that...
    Last edited by pan; 4th March 2011 at 07:58. Reason: spelling corrections

Similar Threads

  1. Problems with scroll in QListWidget
    By VilmarCeller in forum Qt Programming
    Replies: 1
    Last Post: 16th December 2010, 10:54
  2. Replies: 0
    Last Post: 29th November 2010, 05:34
  3. customising the qfledialog box in qt4.5.2
    By netfanatic in forum Newbie
    Replies: 4
    Last Post: 9th March 2010, 10:06
  4. Replies: 0
    Last Post: 28th December 2009, 12:24
  5. Replies: 6
    Last Post: 14th April 2006, 05:39

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.