I've made a custom style based on the existing cleanlooks style. I've got almoast everything the way I want, only I can not change the scroll bar. At least not the way I would like it.

I have to scrollbar images, one for vertical and one for horizontal scrollbar. But when I try to add them the whole scroll bar get's that image instead of just the scrollbar slider.

This is the code where I drawComplexControl():
Qt Code:
  1. void mediaArchiverStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex * option, QPainter * painter, const QWidget * widget) const
  2. {
  3. switch (control) {
  4. case CC_ScrollBar:
  5. {
  6. int delta = (option->state & State_MouseOver) ? 64 : 0;
  7. QColor slightlyOpaqueBlack(100, 100, 100, 63);
  8. QColor semiTransparentWhite(255, 255, 255, 127 + delta);
  9. QColor semiTransparentBlack(10, 10, 10, 127 - delta);
  10.  
  11. int x, y, width, height;
  12. option->rect.getRect(&x, &y, &width, &height);
  13.  
  14. QPainterPath roundRect = roundRectPath(option->rect);
  15. int radius = qMin(width, height) / 2;
  16.  
  17. QBrush brush;
  18. bool darker;
  19.  
  20. const QStyleOptionSlider *sliderOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
  21. if (sliderOption) {
  22. if (sliderOption->orientation == Qt::Vertical)
  23. brush = option->palette.light();
  24. else
  25. brush = option->palette.midlight();
  26. darker = false;
  27. }
  28.  
  29. QStyleOptionSlider mySliderOption;
  30. if (sliderOption) {
  31. mySliderOption = *sliderOption;
  32. if (mySliderOption.palette.currentColorGroup() != QPalette::Disabled) {
  33. if (mySliderOption.state & (State_Enabled)) {
  34. mySliderOption.palette.setBrush(QPalette::ButtonText,
  35. mySliderOption.palette.brightText());
  36. }
  37. }
  38. }
  39. QCleanlooksStyle::drawComplexControl(control, &mySliderOption, painter, widget);
  40.  
  41. painter->save();
  42. painter->setRenderHint(QPainter::Antialiasing, true);
  43. painter->fillPath(roundRect, brush);
  44. if (darker)
  45. painter->fillPath(roundRect, slightlyOpaqueBlack);
  46.  
  47. int penWidth;
  48. if (radius < 10)
  49. penWidth = 3;
  50. else if (radius < 20)
  51. penWidth = 5;
  52. else
  53. penWidth = 7;
  54.  
  55. QPen topPen(semiTransparentWhite, penWidth);
  56. QPen bottomPen(semiTransparentBlack, penWidth);
  57.  
  58. if (option->state & (State_Enabled))
  59. qSwap(topPen, bottomPen);
  60.  
  61. int x1 = x;
  62. int x2 = x + radius;
  63. int x3 = x + width - radius;
  64. int x4 = x + width;
  65.  
  66. if (option->direction == Qt::RightToLeft) {
  67. qSwap(x1, x4);
  68. qSwap(x2, x3);
  69. }
  70.  
  71. QPolygon topHalf;
  72. topHalf << QPoint(x1, y)
  73. << QPoint(x4, y)
  74. << QPoint(x3, y + radius)
  75. << QPoint(x2, y + height - radius)
  76. << QPoint(x1, y + height);
  77.  
  78. painter->setClipPath(roundRect);
  79. painter->setClipRegion(topHalf, Qt::IntersectClip);
  80. painter->setPen(topPen);
  81. painter->drawPath(roundRect);
  82.  
  83. QPolygon bottomHalf = topHalf;
  84. bottomHalf[0] = QPoint(x4, y + height);
  85.  
  86. painter->setClipPath(roundRect);
  87. painter->setClipRegion(bottomHalf, Qt::IntersectClip);
  88. painter->setPen(bottomPen);
  89. painter->drawPath(roundRect);
  90.  
  91. painter->setPen(option->palette.foreground().color());
  92. painter->setClipping(false);
  93. painter->drawPath(roundRect);
  94.  
  95. painter->restore();
  96. }
  97. break;
  98. default:
  99. QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
  100. }
  101. }
To copy to clipboard, switch view to plain text mode 

Thank you for your help!