- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
#include "qrselector.h"
QRSelector::QRSelector(QWidget *parent) :
QWidget(parent){
setupUi(this);
showMaximized();
//showFullScreen();
rubberBand = 0;
//this->autoFillBackground();
//this->setWindowOpacity(0.2);
//this->setAttribute(Qt::WA_TranslucentBackground);
//this->setWindowFlags(Qt::FramelessWindowHint);
}
void QRSelector::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
retranslateUi(this);
break;
default:
break;
}
}
void QRSelector::mousePressEvent(QMouseEvent *e)
{
if(rubberBand)
rubberBand->hide();
origin = e->pos();
if (!rubberBand)
rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
rubberBand->setGeometry(QRect(origin, QSize()));
//rubberBand->setWindowOpacity(0.9);
rubberBand->setPalette(QPalette (Qt::red));
rubberBand->setStyleSheet("background-color: #F5EEA7;");
rubberBand->show();
}
void QRSelector::mouseMoveEvent(QMouseEvent *e)
{
rubberBand->setGeometry(QRect(origin, e->pos()).normalized());
int ww, hh;
ww = origin.x() - e->x();
hh = origin.y() - e->y();
if(ww < 0) ww *= -1;
if(hh < 0) hh *= -1;
label->setText("height: "+QString::number(hh)+" width: "+QString::number(ww));
}
guest 06.01.2011 15:42 # +3