You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
183 lines
8.0 KiB
183 lines
8.0 KiB
14 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/activeqt/examples/simple/simple.doc:45 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>A simple ActiveQt control (executable)</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td 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>
|
||
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>A simple ActiveQt control (executable)</h1>
|
||
|
|
||
|
|
||
|
|
||
|
The ActiveX control in this example is a layouted <a href="qwidget.html">QWidget</a>
|
||
|
with a <a href="qslider.html">QSlider</a>, a <a href="qlcdnumber.html">QLCDNumber</a> and a <a href="qlineedit.html">QLineEdit</a>.
|
||
|
It provides a signal/slot/property interface to change the
|
||
|
values of the slider and the line edit, and to get notified
|
||
|
of any property changes.
|
||
|
<p> It demonstrates the use of <a href="qaxbindable.html#requestPropertyChange">QAxBindable::requestPropertyChange</a>()
|
||
|
and <a href="qaxbindable.html#propertyChanged">QAxBindable::propertyChanged</a>(), and the use of the default
|
||
|
<a href="qaxfactory.html">QAxFactory</a> through the <a href="qaxfactory.html#QAXFACTORY_DEFAULT">QAXFACTORY_DEFAULT</a> macro.
|
||
|
<p>
|
||
|
|
||
|
<p> The Qt implementation of the ActiveX for this example is
|
||
|
<pre> class QSimpleAX : public <a href="qwidget.html">QWidget</a>, public QAxBindable
|
||
|
{
|
||
|
<a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
|
||
|
Q_PROPERTY( QString text READ text WRITE setText )
|
||
|
Q_PROPERTY( int value READ value WRITE setValue )
|
||
|
public:
|
||
|
QSimpleAX( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 )
|
||
|
: <a href="qwidget.html">QWidget</a>( parent, name )
|
||
|
{
|
||
|
<a href="qvboxlayout.html">QVBoxLayout</a> *vbox = new <a href="qvboxlayout.html">QVBoxLayout</a>( this );
|
||
|
|
||
|
slider = new <a href="qslider.html">QSlider</a>( 0, 100, 1, 0, QSlider::Horizontal, this );
|
||
|
LCD = new <a href="qlcdnumber.html">QLCDNumber</a>( 3, this );
|
||
|
edit = new <a href="qlineedit.html">QLineEdit</a>( this );
|
||
|
|
||
|
<a name="x2528"></a> connect( slider, SIGNAL( <a href="qslider.html#valueChanged">valueChanged</a>( int ) ), this, SLOT( setValue(int) ) );
|
||
|
<a name="x2523"></a> connect( edit, SIGNAL(<a href="qlineedit.html#textChanged">textChanged</a>(const <a href="qstring.html">QString</a>&)), this, SLOT(setText(const <a href="qstring.html">QString</a>&)) );
|
||
|
|
||
|
vbox-><a href="qboxlayout.html#addWidget">addWidget</a>( slider );
|
||
|
vbox-><a href="qboxlayout.html#addWidget">addWidget</a>( LCD );
|
||
|
vbox-><a href="qboxlayout.html#addWidget">addWidget</a>( edit );
|
||
|
}
|
||
|
|
||
|
<a href="qstring.html">QString</a> text() const
|
||
|
{
|
||
|
<a name="x2522"></a> return edit-><a href="qlineedit.html#text">text</a>();
|
||
|
}
|
||
|
int value() const
|
||
|
{
|
||
|
<a name="x2527"></a> return slider-><a href="qslider.html#value">value</a>();
|
||
|
}
|
||
|
|
||
|
signals:
|
||
|
void someSignal();
|
||
|
void valueChanged(int);
|
||
|
void textChanged(const <a href="qstring.html">QString</a>&);
|
||
|
|
||
|
public slots:
|
||
|
void setText( const <a href="qstring.html">QString</a> &string )
|
||
|
{
|
||
|
if ( !requestPropertyChange( "text" ) )
|
||
|
return;
|
||
|
|
||
|
<a name="x2525"></a> edit-><a href="qobject.html#blockSignals">blockSignals</a>( TRUE );
|
||
|
<a name="x2521"></a> edit-><a href="qlineedit.html#setText">setText</a>( string );
|
||
|
edit-><a href="qobject.html#blockSignals">blockSignals</a>( FALSE );
|
||
|
emit someSignal();
|
||
|
emit textChanged( string );
|
||
|
|
||
|
propertyChanged( "text" );
|
||
|
}
|
||
|
void about()
|
||
|
{
|
||
|
<a name="x2524"></a> QMessageBox::<a href="qmessagebox.html#information">information</a>( this, "About QSimpleAX", "This is a Qt widget, and this slot has been\n"
|
||
|
"called through ActiveX/OLE automation!" );
|
||
|
}
|
||
|
void setValue( int i )
|
||
|
{
|
||
|
if ( !requestPropertyChange( "value" ) )
|
||
|
return;
|
||
|
slider-><a href="qobject.html#blockSignals">blockSignals</a>( TRUE );
|
||
|
<a name="x2526"></a> slider-><a href="qslider.html#setValue">setValue</a>( i );
|
||
|
slider-><a href="qobject.html#blockSignals">blockSignals</a>( FALSE );
|
||
|
LCD-><a href="qlcdnumber.html#display">display</a>( i );
|
||
|
emit valueChanged( i );
|
||
|
|
||
|
propertyChanged( "value" );
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
<a href="qslider.html">QSlider</a> *slider;
|
||
|
<a href="qlcdnumber.html">QLCDNumber</a> *LCD;
|
||
|
<a href="qlineedit.html">QLineEdit</a> *edit;
|
||
|
};
|
||
|
</pre>
|
||
|
<p> The control is exported using the default <a href="qaxfactory.html">QAxFactory</a>
|
||
|
<pre> QAXFACTORY_DEFAULT(QSimpleAX,
|
||
|
"{DF16845C-92CD-4AAB-A982-EB9840E74669}",
|
||
|
"{616F620B-91C5-4410-A74E-6B81C76FFFE0}",
|
||
|
"{E1816BBA-BF5D-4A31-9855-D6BA432055FF}",
|
||
|
"{EC08F8FC-2754-47AB-8EFE-56A54057F34E}",
|
||
|
"{A095BA0C-224F-4933-A458-2DD7F6B85D8F}")
|
||
|
</pre>
|
||
|
<p> To build the example you must first build the <a href="qaxserver.html">QAxServer</a> library. Then run qmake and your make tool in
|
||
|
<tt>examples/simple</tt>.
|
||
|
<p> <hr>
|
||
|
<p> The <a href="qaxserver-demo-simple.html">demonstration</a> requires your
|
||
|
WebBrowser to support ActiveX controls, and scripting to be enabled.
|
||
|
<p> The simple ActiveX control is embedded using the <tt><object></tt> tag.
|
||
|
|
||
|
|
||
|
<pre> <object ID="QSimpleAX" CLASSID="CLSID:DF16845C-92CD-4AAB-A982-EB9840E74669"
|
||
|
CODEBASE=http://www.trolltech.com/demos/simpleax.cab>
|
||
|
<PARAM NAME="text" VALUE="A simple control">
|
||
|
<PARAM NAME="value" VALUE="1">
|
||
|
[Object not available! Did you forget to build and register the server?]
|
||
|
</object>
|
||
|
</pre>
|
||
|
<p> A simple HTML button is connected to the <a href="activeqt.html#ActiveQt">ActiveQt</a>'s about() slot.
|
||
|
<pre> <FORM>
|
||
|
<INPUT TYPE="BUTTON" VALUE="About..." onClick="QSimpleAX.about()">
|
||
|
</FORM>
|
||
|
</pre>
|
||
|
<p> A second ActiveX control - the standard Calendar Control - is instantiated
|
||
|
<pre> <object ID="Calendar" CLASSID="CLSID:8E27C92B-1264-101C-8A2F-040224009C02">
|
||
|
[Standard Calendar control not available!]
|
||
|
<PARAM NAME="day" VALUE="1">
|
||
|
</object>
|
||
|
</pre>
|
||
|
<p> Events from the ActiveX controls are handled using both Visual Basic Script
|
||
|
and JavaScript.
|
||
|
<pre> <SCRIPT LANGUAGE=VBScript>
|
||
|
Sub Calendar_Click()
|
||
|
MsgBox( "Calendar Clicked!" )
|
||
|
End Sub
|
||
|
|
||
|
Sub QSimpleAX_TextChanged( str )
|
||
|
document.title = str
|
||
|
End Sub
|
||
|
</SCRIPT>
|
||
|
<SCRIPT LANGUAGE=JavaScript>
|
||
|
function QSimpleAX::ValueChanged( Newvalue )
|
||
|
{
|
||
|
Calendar.Day = Newvalue;
|
||
|
}
|
||
|
</SCRIPT>
|
||
|
</pre><p>See also <a href="qaxserver-examples.html">The QAxServer Examples</a>.
|
||
|
|
||
|
<!-- eof -->
|
||
|
<p><address><hr><div align=center>
|
||
|
<table width=100% cellspacing=0 border=0><tr>
|
||
|
<td>Copyright © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|