1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>
Qt Toolkit - trivial/trivial.cpp example file
</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>Very Trivial Example</h1>
This example is extremely trivial, and thus useful for
investigating problems you might have installing the
extension.
<p>
To build the example, you must first build the
<a href=nsplugin.html>Qt Netscape Plugin Extension</a> library.
Then type <tt>make</tt> in <tt>extensions/nsplugin/examples/trivial/</tt>
and copy the resulting <tt>trivial.so</tt> or <tt>nptrivial.dll</tt>
to the Plugins directory of your WWW browser.
<p>
<EMBED TYPE=trivial/very WIDTH=100 HEIGHT=100>
<pre>// Qt stuff
#include "<a name="qnp.h"></a><a href="qnp-h.html">qnp.h</a>"
#include <<a name="qpainter.h"></a><a href="qpainter-h.html">qpainter.h</a>>
#include <<a name="qmessagebox.h"></a><a href="qmessagebox-h.html">qmessagebox.h</a>>
class Trivial : public QNPWidget {
Q_OBJECT
public:
void mouseReleaseEvent(<a name="QMouseEvent"></a><a href="qmouseevent.html">QMouseEvent</a>* event)
{
<a name="QMessageBox::aboutQt"></a><a href="qmessagebox.html#b72270">QMessageBox::aboutQt</a>(this);
}
void paintEvent(<a name="QPaintEvent"></a><a href="qpaintevent.html">QPaintEvent</a>* event)
{
<a name="QPainter"></a><a href="qpainter.html">QPainter</a> p(this);
p.<a name="setClipRect"></a><a href="qpainter.html#898839">setClipRect</a>(event-><a name="rect"></a><a href="qpaintevent.html#2d6e18">rect</a>());
int w = width();
p.<a name="drawRect"></a><a href="qpainter.html#4c0077">drawRect</a>(rect());
p.<a name="drawText"></a><a href="qpainter.html#0f088f">drawText</a>(w/8, 0, w-w/4, height(), AlignCenter|WordBreak, "Trivial!");
}
};
class TrivialInstance : public QNPInstance {
Q_OBJECT
public:
<a name="QNPWidget"></a><a href="qnpwidget.html">QNPWidget</a>* newWindow()
{
return new Trivial;
}
void print(<a href="qpainter.html">QPainter</a>* p)
{
p-><a href="qpainter.html#0f088f">drawText</a>(0,0,"Hello");
}
};
class TrivialPlugin : public QNPlugin {
public:
<a name="QNPInstance"></a><a href="qnpinstance.html">QNPInstance</a>* newInstance()
{
return new TrivialInstance;
}
const char* getMIMEDescription() const
{
return "trivial/very:xxx:Trivial and useless";
}
const char * getPluginNameString() const
{
return "Trivial Qt-based Plugin";
}
const char * getPluginDescriptionString() const
{
return "A Qt-based LiveConnected plug-in that does nothing";
}
};
<a name="QNPlugin"></a><a href="qnplugin.html">QNPlugin</a>* QNPlugin::create()
{
return new TrivialPlugin;
}
#include "trivial.moc"
</pre>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|