source: trunk/doc/html/trivial-nsplugin-example.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 4.0 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/nsplugin/examples/trivial/trivial.doc:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>Trivial Example</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Trivial Example</h1>
33
34
35
36<p> This example is trivial, and thus useful for
37investigating problems you might have installing the
38extension.
39<p> To build the example, you must first build the
40<a href="netscape-plugin.html">Qt Netscape Plugin Extension</a> library.
41Then type <tt>make</tt> in <tt>extensions/nsplugin/examples/trivial/</tt>
42and copy the resulting <tt>trivial.so</tt> or <tt>nptrivial.dll</tt>
43to the Plugins directory of your WWW browser.
44<p> <EMBED TYPE=trivial/very WIDTH=100 HEIGHT=100>
45<p> <hr>
46Implementation:
47<p> <pre>// Qt stuff
48#include "qnp.h"
49#include &lt;<a href="qpainter-h.html">qpainter.h</a>&gt;
50#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;
51
52class Trivial : public <a href="qnpwidget.html">QNPWidget</a> {
53 <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
54public:
55 void mouseReleaseEvent(QMouseEvent* event)
56 {
57<a name="x2736"></a> QMessageBox::<a href="qmessagebox.html#aboutQt">aboutQt</a>(this);
58 }
59
60 void paintEvent(QPaintEvent* event)
61 {
62 <a href="qpainter.html">QPainter</a> p(this);
63<a name="x2739"></a> p.<a href="qpainter.html#setClipRect">setClipRect</a>(event-&gt;rect());
64 int w = width();
65<a name="x2737"></a> p.<a href="qpainter.html#drawRect">drawRect</a>(rect());
66<a name="x2738"></a> p.<a href="qpainter.html#drawText">drawText</a>(w/8, 0, w-w/4, height(), AlignCenter|WordBreak, "Trivial!");
67 }
68};
69
70class TrivialInstance : public <a href="qnpinstance.html">QNPInstance</a> {
71 Q_OBJECT
72public:
73 <a href="qnpwidget.html">QNPWidget</a>* newWindow()
74 {
75 return new Trivial;
76 }
77
78 void print(QPainter* p)
79 {
80 p-&gt;<a href="qpainter.html#drawText">drawText</a>(0,0,"Hello");
81 }
82};
83
84class TrivialPlugin : public <a href="qnplugin.html">QNPlugin</a> {
85public:
86 <a href="qnpinstance.html">QNPInstance</a>* newInstance()
87 {
88 return new TrivialInstance;
89 }
90
91 const char* getMIMEDescription() const
92 {
93 return "trivial/very:xxx:Trivial and useless";
94 }
95
96 const char * getPluginNameString() const
97 {
98 return "Trivial Qt-based Plugin";
99 }
100
101 const char * getPluginDescriptionString() const
102 {
103 return "A Qt-based LiveConnected plug-in that does nothing";
104 }
105
106};
107
108QNPlugin* QNPlugin::create()
109{
110 return new TrivialPlugin;
111}
112
113#include "trivial.moc"
114</pre>
115
116<p>See also <a href="nsplugin-examples.html">Netscape Plugin Examples</a>.
117
118<!-- eof -->
119<p><address><hr><div align=center>
120<table width=100% cellspacing=0 border=0><tr>
121<td>Copyright &copy; 2007
122<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
123<td align=right><div align=right>Qt 3.3.8</div>
124</table></div></address></body>
125</html>
Note: See TracBrowser for help on using the repository browser.