Hi,

as already discussed here and here it should be possible to paint modify the appearance of the QRubberBand by making a subclass and overwriting the paintEvent. The rubberband should be displayed on QGraphicsView to select some items on a QGraphicsScene. I'm able to modify the frame color but the background of the rubber band rect remains completely transparent (white). Here is my implementation of the QRubberBand subclass

Qt Code:
  1. #include "SelectionFrame.h"
  2. #include <QPaintEvent>
  3. #include <QPainter>
  4. #include <QDebug>
  5.  
  6. SelectionFrame::SelectionFrame(Shape shape, QWidget *parent) :
  7. QRubberBand(shape, parent)
  8. {
  9. _border_color = QColor(0, 83, 235);
  10. _background_color = QColor(51, 122, 255);
  11. }
  12.  
  13. SelectionFrame::~SelectionFrame()
  14. {
  15. }
  16.  
  17. void SelectionFrame::paintEvent(QPaintEvent *event)
  18. {
  19. Q_UNUSED(event);
  20.  
  21. QPainter painter;
  22. QPen pen = QPen(_border_color);
  23. pen.setWidth(5);
  24. pen.setStyle(Qt::DashLine);
  25.  
  26. QBrush brush = QBrush(_background_color);
  27.  
  28. painter.begin(this);
  29. painter.setPen(pen);
  30. painter.setOpacity(0.5);
  31. painter.setBrush(brush);
  32. painter.drawRect(event->rect());
  33. painter.end();
  34. }
To copy to clipboard, switch view to plain text mode 

As the painter's pen has been set to dashed, I think I can see, that there is an additional border painted on top of the dashed line with the correctly set transparency. The background is however not painter. Does anyone have a suggestion how this can be done right?