1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<title>Qt 4.0: gradients.h Example File (demos/gradients/gradients.h)</title>
7
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
8
a:link { color: #004faf; text-decoration: none }
9
a:visited { color: #672967; text-decoration: none }
10
td.postheader { font-family: sans-serif }
11
tr.address { font-family: sans-serif }
12
body { background: #ffffff; color: black; }</style>
15
<table border="0" cellpadding="0" cellspacing="0" width="100%">
17
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
18
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
19
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">gradients.h Example File<br /><small><small>demos/gradients/gradients.h</small></small></h1>
20
<pre> #ifndef GRADIENTS_H
23
#include <QtGui>
25
#include "arthurwidgets.h"
29
class ShadeWidget : public QWidget
40
ShadeWidget(ShadeType type, QWidget *parent);
42
void setGradientStops(const QGradientStops &stops);
44
void paintEvent(QPaintEvent *e);
46
QSize sizeHint() const { return QSize(150, 40); }
47
QPolygonF points() const;
49
HoverPoints *hoverPoints() const { return m_hoverPoints; }
59
ShadeType m_shade_type;
61
HoverPoints *m_hoverPoints;
62
QLinearGradient m_alpha_gradient;
65
class GradientEditor : public QWidget
69
GradientEditor(QWidget *parent);
71
void setGradientStops(const QGradientStops &stops);
77
void gradientStopsChanged(const QGradientStops &stops);
80
ShadeWidget *m_red_shade;
81
ShadeWidget *m_green_shade;
82
ShadeWidget *m_blue_shade;
83
ShadeWidget *m_alpha_shade;
86
class GradientRenderer : public ArthurFrame
90
GradientRenderer(QWidget *parent);
91
void paint(QPainter *p);
93
QSize sizeHint() const { return QSize(400, 400); }
95
HoverPoints *hoverPoints() const { return m_hoverPoints; }
96
void mousePressEvent(QMouseEvent *e);
99
void setGradientStops(const QGradientStops &stops);
101
void setPadSpread() { m_spread = QGradient::PadSpread; update(); }
102
void setRepeatSpread() { m_spread = QGradient::RepeatSpread; update(); }
103
void setReflectSpread() { m_spread = QGradient::ReflectSpread; update(); }
105
void setLinearGradient() { m_gradientType = Qt::LinearGradientPattern; update(); }
106
void setRadialGradient() { m_gradientType = Qt::RadialGradientPattern; update(); }
107
void setConicalGradient() { m_gradientType = Qt::ConicalGradientPattern; update(); }
110
QGradientStops m_stops;
111
HoverPoints *m_hoverPoints;
113
QGradient::Spread m_spread;
114
Qt::BrushStyle m_gradientType;
117
class GradientWidget : public QWidget
121
GradientWidget(QWidget *parent);
124
void setDefault1() { setDefault(1); }
125
void setDefault2() { setDefault(2); }
126
void setDefault3() { setDefault(3); }
127
void setDefault4() { setDefault(4); }
130
void setDefault(int i);
132
GradientRenderer *m_renderer;
133
GradientEditor *m_editor;
135
QRadioButton *m_linearButton;
136
QRadioButton *m_radialButton;
137
QRadioButton *m_conicalButton;
138
QRadioButton *m_padSpreadButton;
139
QRadioButton *m_reflectSpreadButton;
140
QRadioButton *m_repeatSpreadButton;
144
#endif // GRADIENTS_H</pre>
145
<p /><address><hr /><div align="center">
146
<table width="100%" cellspacing="0" border="0"><tr class="address">
147
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
148
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
149
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
150
</tr></table></div></address></body>