hi there,

I gotta draw a rounded rectangle n fit MultiSlider widget inside of it. I was told I'd be able to present it with setmas().
here's the code, please add the required code for me.

Qt Code:
  1. void QtMultiSlider::paintEvent(QPaintEvent * event)
  2. {
  3. Q_UNUSED(event)
  4.  
  5. if (!isVisible())
  6. return;
  7.  
  8. QPainter painter;
  9. painter.begin(this);
  10.  
  11. painter.setPen(Qt::blue);
  12. painter.setBrush(Qt::SolidPattern);
  13. QRect rect(50, 50, 240, 100);
  14. painter.setRenderHint(QPainter::Antialiasing, true);
  15. painter.drawRoundedRect(rect, 25, 25, Qt::RelativeSize);
  16.  
  17. int spacing = 30;
  18. int labelHeight = 0;
  19.  
  20. int valueBarWidth = 300;
  21.  
  22. // Calculating the maximum string size
  23.  
  24. int valueBarX = spacing;
  25. int valueBarBottomY = 0;
  26.  
  27. QSizeF originalSize = m_rendererValueBarTop->defaultSize();
  28. QSizeF targetSize = originalSize;
  29. targetSize.scale(QSizeF(valueBarWidth, originalSize.height()), Qt::KeepAspectRatio);
  30. qreal scaleRatio = targetSize.width() /
  31. originalSize.width();
  32.  
  33. QSize valueBarBottomSize = m_rendererValueBarBottom->defaultSize() * scaleRatio;
  34.  
  35. valueBarBottomY = height() - labelHeight - 20
  36. - valueBarBottomSize.height();
  37.  
  38. m_valueBarRightRect = QRect(QPoint(valueBarX, 20),
  39. QSize(valueBarWidth, valueBarBottomY));
  40.  
  41. m_rendererValueBar->render(&painter, m_valueBarRightRect);
  42.  
  43. int filledPixels = ((double)value()) / maximum() * m_valueBarRightRect.height();
  44. QRect filledRect = m_valueBarRightRect;
  45. filledRect.setTop(filledRect.bottom() - filledPixels);
  46. m_rendererValueBarFilled->render(&painter, filledRect);
  47.  
  48.  
  49. painter.end();
  50.  
  51. }
To copy to clipboard, switch view to plain text mode