-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.cpp
More file actions
47 lines (37 loc) · 1.37 KB
/
object.cpp
File metadata and controls
47 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
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
#include "object.h"
#include <QPainter>
#include <QApplication>
#include <QDesktopWidget>
Object::Object(QWidget *parent) :
QWidget(parent)
{
this->setPalette(Qt::transparent);
this->setEnabled(false);
this->setWindowFlags(Qt::WindowStaysOnBottomHint|Qt::FramelessWindowHint|Qt::WindowType_Mask);//
this->setAttribute(Qt::WA_DeleteOnClose,true);
this->setAttribute(Qt::WA_X11DoNotAcceptFocus,true);
//this->setAttribute(Qt::WA_X11NetWmWindowTypeUtility,true);
this->setAttribute(Qt::WA_TransparentForMouseEvents,true);
this->setAttribute(Qt::WA_NoSystemBackground,true);
this->setAttribute(Qt::WA_PaintOnScreen,false);
this->setAttribute(Qt::WA_TranslucentBackground,true);
this->setFocusPolicy(Qt::NoFocus);
}
void Object::paintEvent(QPaintEvent * /* event */)
{
QPixmap originalPixmap;
originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(),this->pos().x(),this->pos().y(),this->geometry().width(),this->geometry().height());
QPainter painter(this);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
// painter.translate(50, 50);
// painter.rotate(60.0);
// painter.scale(0.7, 0.7);
// painter.translate(-50, -50);
// painter.drawPixmap(this->rect(),originalPixmap);
painter.drawPixmap(this->rect(), pix);
}
void Object::setPixmap(QPixmap pix)
{
this->pix=pix;
update();
}