| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
#include <QApplication> |
| 5 |
#include <QPushButton> |
| 6 |
#include <QVBoxLayout> |
| 7 |
|
| 8 |
class TopWidget : public QWidget |
| 9 |
{ |
| 10 |
Q_OBJECT |
| 11 |
public: |
| 12 |
TopWidget(QWidget *parent = nullptr) : QWidget(parent) |
| 13 |
{ |
| 14 |
QVBoxLayout *layout = new QVBoxLayout; |
| 15 |
QPushButton *button = new QPushButton("Change app icon"); |
| 16 |
connect(button, SIGNAL(clicked()), this, SLOT(changeIcon())); |
| 17 |
layout->addWidget(button); |
| 18 |
setLayout(layout); |
| 19 |
} |
| 20 |
public slots: |
| 21 |
void changeIcon() |
| 22 |
{ |
| 23 |
QPixmap pix(32, 32); |
| 24 |
pix.fill(Qt::red); |
| 25 |
QIcon i(pix); |
| 26 |
qApp->setWindowIcon(i); |
| 27 |
} |
| 28 |
}; |
| 29 |
|
| 30 |
#include "main.moc" |
| 31 |
|
| 32 |
int main(int argc, char **argv) |
| 33 |
{ |
| 34 |
QApplication a(argc, argv); |
| 35 |
TopWidget w; |
| 36 |
w.show(); |
| 37 |
return a.exec(); |
| 38 |
} |