PDA

View Full Version : Customising the scroll bar in a QListWidget



balasaravanan
4th March 2011, 06:39
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

pan
4th March 2011, 07:57
First thing I notice is

vertical {
border: 2px solid grey;
background: #32CC99;
height: 15px;
margin: 0px 20px 0 20px;}

Should be:

vertical {
border: 2px solid grey;
background: #32CC99;
width: 15px;
margin: 20px 0px 20px 0px ;}

Something like that...