Skip to content

Instantly share code, notes, and snippets.

@Temptationx
Created August 26, 2014 21:09
Show Gist options
  • Save Temptationx/15aba87f5827f3e0ec51 to your computer and use it in GitHub Desktop.
Save Temptationx/15aba87f5827f3e0ec51 to your computer and use it in GitHub Desktop.
#include <QRubberBand>
class RubberBand : public QRubberBand
{
Q_OBJECT
public:
RubberBand(QWidget *parent = 0, QColor c = QColor("red"), Shape s = QRubberBand::Rectangle);
void paintEvent(QPaintEvent *);
private:
QColor color;
};
RubberBand::RubberBand(QWidget *parent, QColor c, Shape s) :
QRubberBand(s, parent),
color(c)
{
}
void RubberBand::paintEvent(QPaintEvent *)
{
QPen pen;
pen.setStyle(Qt::DashLine);
pen.setColor(color);
QPainter painter(this);
painter.setPen(pen);
painter.drawRect(rect().adjusted(0,0,-1,-1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment