KWin
Loading...
Searching...
No Matches
paste.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#include <QClipboard>
10#include <QGuiApplication>
11#include <QPainter>
12#include <QRasterWindow>
13#include <QTimer>
14
15class Window : public QRasterWindow
16{
17 Q_OBJECT
18public:
19 explicit Window();
20 ~Window() override;
21
22protected:
23 void paintEvent(QPaintEvent *event) override;
24};
25
27 : QRasterWindow()
28{
29}
30
31Window::~Window() = default;
32
33void Window::paintEvent(QPaintEvent *event)
34{
35 QPainter p(this);
36 p.fillRect(0, 0, width(), height(), Qt::blue);
37}
38
39int main(int argc, char *argv[])
40{
41 QGuiApplication app(argc, argv);
42 QObject::connect(app.clipboard(), &QClipboard::changed, &app,
43 [] {
44 if (qApp->clipboard()->text() == QLatin1String("test")) {
45 QTimer::singleShot(100, qApp, &QCoreApplication::quit);
46 }
47 });
48 std::unique_ptr<Window> w(new Window);
49 w->setGeometry(QRect(0, 0, 100, 200));
50 w->show();
51
52 return app.exec();
53}
54
55#include "paste.moc"
~Window() override
void paintEvent(QPaintEvent *event) override