Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtGui>
5#include <QApplication>
6
7class MyPushButton : public QPushButton
8{
9public:
10 MyPushButton(QWidget *parent = nullptr);
11
12 void paintEvent(QPaintEvent *) override;
13};
14
16 : QPushButton(parent)
17{
18}
19
35
36
37
38class MyStyle : public QStyle
39{
40public:
41
43 QPainter *painter, const QWidget *widget) override;
44};
45
48 const QStyleOption *option,
50 const QWidget *widget)
51{
52 if (element == PE_FrameFocusRect) {
54 qstyleoption_cast<const QStyleOptionFocusRect *>(option);
55 if (focusRectOption) {
56 // ...
57 }
58 }
59 // ...
60}
62
63int main(int argc, char *argv[])
64{
65 QApplication app(argc, argv);
67 button.show();
68 return app.exec();
69}
MyPushButton(QWidget *parent=nullptr)
Definition main.cpp:15
void paintEvent(QPaintEvent *) override
[0]
Definition main.cpp:21
[0]
Definition main.cpp:39
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) override
[4]
Definition main.cpp:47
QIcon icon
the icon shown on the button
QString text
the text shown on the button
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
bool isDefault() const
\variable QStyleOptionHeaderV2::textElideMode
\variable QStyleOption::palette
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ State_Sunken
Definition qstyle.h:69
@ State_Raised
Definition qstyle.h:68
@ CE_PushButton
Definition qstyle.h:171
PrimitiveElement
This enum describes the various primitive elements.
Definition qstyle.h:102
@ PE_FrameFocusRect
Definition qstyle.h:106
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
QStyle * style() const
Definition qwidget.cpp:2600
QOpenGLWidget * widget
[1]
int main()
[0]
QPushButton * button
[2]
const QStyleOptionFocusRect * focusRectOption
[0]
GLuint GLenum option
QApplication app(argc, argv)
[0]
QPainter painter(this)
[7]