Created
August 26, 2014 21:09
-
-
Save Temptationx/15aba87f5827f3e0ec51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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