| 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"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { 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 Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main 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 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 | 
|---|
| 37 | investigating problems you might have installing the | 
|---|
| 38 | extension. | 
|---|
| 39 | <p> To build the example, you must first build the | 
|---|
| 40 | <a href="netscape-plugin.html">Qt Netscape Plugin Extension</a> library. | 
|---|
| 41 | Then type <tt>make</tt> in <tt>extensions/nsplugin/examples/trivial/</tt> | 
|---|
| 42 | and copy the resulting <tt>trivial.so</tt> or <tt>nptrivial.dll</tt> | 
|---|
| 43 | to the Plugins directory of your WWW browser. | 
|---|
| 44 | <p> <EMBED TYPE=trivial/very WIDTH=100 HEIGHT=100> | 
|---|
| 45 | <p> <hr> | 
|---|
| 46 | Implementation: | 
|---|
| 47 | <p> <pre>// Qt stuff | 
|---|
| 48 | #include "qnp.h" | 
|---|
| 49 | #include <<a href="qpainter-h.html">qpainter.h</a>> | 
|---|
| 50 | #include <<a href="qmessagebox-h.html">qmessagebox.h</a>> | 
|---|
| 51 |  | 
|---|
| 52 | class Trivial : public <a href="qnpwidget.html">QNPWidget</a> { | 
|---|
| 53 | <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> | 
|---|
| 54 | public: | 
|---|
| 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->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 |  | 
|---|
| 70 | class TrivialInstance : public <a href="qnpinstance.html">QNPInstance</a> { | 
|---|
| 71 | Q_OBJECT | 
|---|
| 72 | public: | 
|---|
| 73 | <a href="qnpwidget.html">QNPWidget</a>* newWindow() | 
|---|
| 74 | { | 
|---|
| 75 | return new Trivial; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | void print(QPainter* p) | 
|---|
| 79 | { | 
|---|
| 80 | p-><a href="qpainter.html#drawText">drawText</a>(0,0,"Hello"); | 
|---|
| 81 | } | 
|---|
| 82 | }; | 
|---|
| 83 |  | 
|---|
| 84 | class TrivialPlugin : public <a href="qnplugin.html">QNPlugin</a> { | 
|---|
| 85 | public: | 
|---|
| 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 |  | 
|---|
| 108 | QNPlugin* 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 © 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> | 
|---|