53 #include <QApplication>
54 #include <QFocusEvent>
55 #include <QHBoxLayout>
58 #include <QMouseEvent>
73 g.setColorAt(0,
QColor(
"lightsteelblue"));
79 p->drawText(20, 30,
QLatin1String(
"This is an OpenGL based QWindow"));
86 p->translate(-bounds.
width() / 2.0, -bounds.
height() / 2.0);
95 p->drawPolyline(m_polygon);
103 m_polygon.
append(
e->position().toPoint());
111 m_polygon.
append(
e->position().toPoint());
120 m_polygon.
append(
e->position().toPoint());
152 bool m_mouseDown =
false;
153 bool m_focus =
false;
157 int main(
int argc,
char *argv[])
172 window->setGeometry(100, 100, 300, 200);
183 #include "windowcontainer.moc"
The QApplication class manages the GUI application's control flow and main settings.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
The QColor class provides colors based on RGB, HSV or CMYK values.
The QFocusEvent class contains event parameters for widget focus events. \inmodule QtGui.
The QHBoxLayout class lines up widgets horizontally.
The QKeyEvent class describes a key event.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLineEdit widget is a one-line text editor.
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush.
void append(parameter_type t)
The QMouseEvent class contains parameters that describe a mouse event.
The QPainter class performs low-level painting on widgets and other paint devices.
The QPolygon class provides a list of points using integer precision. \inmodule QtGui.
The QRect class defines a rectangle in the plane using integer precision.
constexpr int height() const noexcept
constexpr void translate(int dx, int dy) noexcept
constexpr int width() const noexcept
The QString class provides a Unicode character string.
QString trimmed() const &
int width
the width of the window's geometry
int height
the height of the window's geometry
[Window class definition]
void focusInEvent(QFocusEvent *) override
void keyReleaseEvent(QKeyEvent *) override
void mouseMoveEvent(QMouseEvent *e) override
void focusOutEvent(QFocusEvent *) override
void keyPressEvent(QKeyEvent *e) override
void render(QPainter *p) override
[2]
void mouseReleaseEvent(QMouseEvent *e) override
void mousePressEvent(QMouseEvent *e) override
QApplication app(argc, argv)
[0]
int main(int argc, char *argv[])
[1]