source: trunk/doc/src/qaxserver.qdoc@ 348

Last change on this file since 348 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 33.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43 \module QAxServer
44 \title QAxServer Module
45 \contentspage Qt's Modules
46 \previouspage QAxContainer
47 \nextpage QtDBus module
48 \ingroup modules
49
50 \brief The QAxServer module is a Windows-only static library that
51 you can use to turn a standard Qt binary into a COM server.
52
53 The QAxServer module is part of the \l ActiveQt framework. It
54 consists of three classes:
55
56 \list
57 \o QAxFactory defines a factory for the creation of COM objects.
58 \o QAxBindable provides an interface between the Qt widget and the
59 COM object.
60 \o QAxAggregated can be subclassed to implement additional COM interfaces.
61 \endlist
62
63 Some \l{Qt Examples#ActiveQt}{example implementations} of ActiveX
64 controls and COM objects are provided.
65
66 \sa {ActiveQt Framework}
67
68 Topics:
69
70 \tableofcontents
71
72 \section1 Using the Library
73
74 To turn a standard Qt application into a COM server using the
75 QAxServer library you must add \c qaxserver as a CONFIG setting
76 in your \c .pro file.
77
78 An out-of-process executable server is generated from a \c .pro
79 file like this:
80
81 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 0
82
83 To build an in-process server, use a \c .pro file like this:
84 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 1
85
86 The files \c qaxserver.rc and \c qaxserver.def are part of the
87 framework and can be used from their usual location (specify a
88 path in the \c .pro file), or copied into the project directory.
89 You can modify these files as long as it includes any file as the
90 type library entry, ie. you can add version information or specify
91 a different toolbox icon.
92
93 The \c qaxserver configuration will cause the \c qmake tool to add the
94 required build steps to the build system:
95
96 \list
97 \o Link the binary against \c qaxserver.lib instead of \c qtmain.lib
98 \o Call the \l idc tool to generate an IDL file for the COM server
99 \o Compile the IDL into a type library using the MIDL tool (part of the
100 compiler installation)
101 \o Attach the resulting type library as a binary resource to the server
102 binary (again using the \l idc tool)
103 \o Register the server
104 \endlist
105
106 Note that the QAxServer build system is not supported on Windows 98/ME
107 (attaching of resources to a binary is not possible there), but a server
108 built on Windows NT/2000/XP will work on previous Windows versions as well.
109
110 To skip the post-processing step, also set the \c qaxserver_no_postlink
111 configuration.
112
113 Additionally you can specify a version number using the \c VERSION
114 variable, e.g.
115
116 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 2
117
118 The version number specified will be used as the version of the type
119 library and of the server when registering.
120
121 \section2 Out-of-Process vs. In-Process
122
123 Whether your COM server should run as a stand-alone executable
124 or as a shared library in the client process depends mainly on the
125 type of COM objects you want to provide in the server.
126
127 An executable server has the advantage of being able to run as a
128 stand-alone application, but adds considerable overhead to the
129 communication between the COM client and the COM object. If the
130 control has a programming error only the server process running
131 the control will crash, and the client application will probably
132 continue to run. Not all COM clients support executable servers.
133
134 An in-process server is usually smaller and has faster startup
135 time. The communication between client and server is done directly
136 through virtual function calls and does not introduce the overhead
137 required for remote procedure calls. However, if the server crashes the
138 client application is likely to crash as well, and not every
139 functionality is available for in-process servers (i.e. register in
140 the COM's running-object-table).
141
142 Both server types can use Qt either as a shared library, or statically
143 linked into the server binary.
144
145 \section2 Typical Errors During the Post-Build Steps
146
147 For the ActiveQt specific post-processing steps to work the
148 server has to meet some requirements:
149
150 \list
151 \o All controls exposed can be created with nothing but a QApplication
152 instance being present
153 \o The initial linking of the server includes a temporary type
154 library resource
155 \o All dependencies required to run the server are in the system path
156 (or in the path used by the calling environment; note that Visual
157 Studio has its own set of environment variables listed in the
158 Tools|Options|Directories dialog).
159 \endlist
160
161 If those requirements are not met one ore more of the following
162 errors are likely to occur:
163
164 \section3 The Server Executable Crashes
165
166 To generate the IDL the widgets exposed as ActiveX controls need to
167 be instantiated (the constructor is called). At this point, nothing
168 else but a QApplication object exists. Your widget constructor must
169 not rely on any other objects to be created, e.g. it should check for
170 null-pointers.
171
172 To debug your server run it with -dumpidl outputfile and check where
173 it crashes.
174
175 Note that no functions of the control are called.
176
177 \section3 The Server Executable Is Not a Valid Win32 Application
178
179 Attaching the type library corrupted the server binary. This is a
180 bug in Windows and happens only with release builds.
181
182 The first linking step has to link a dummy type library into the
183 executable that can later be replaced by idc. Add a resource file
184 with a type library to your project as demonstrated in the examples.
185
186 \section3 "Unable to locate DLL"
187
188 The build system needs to run the server executable to generate
189 the interface definition, and to register the server. If a dynamic
190 link library the server links against is not in the path this
191 might fail (e.g. Visual Studio calls the server using the
192 enivronment settings specified in the "Directories" option). Make
193 sure that all DLLs required by your server are located in a
194 directory that is listed in the path as printed in the error
195 message box.
196
197 \section3 "Cannot open file ..."
198
199 The ActiveX server could not shut down properly when the last
200 client stopped using it. It usually takes about two seconds for
201 the application to terminate, but you might have to use the task
202 manager to kill the process (e.g. when a client doesn't release
203 the controls properly).
204
205 \section1 Implementing Controls
206
207 To implement a COM object with Qt, create a subclass of QObject
208 or any existing QObject subclass. If the class is a subclass of QWidget,
209 the COM object will be an ActiveX control.
210
211 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 3
212
213 The Q_OBJECT macro is required to provide the meta object information
214 about the widget to the ActiveQt framework.
215
216 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 4
217
218 Use the Q_CLASSINFO() macro to specify the COM identifiers for the COM
219 object. \c ClassID and \c InterfaceID are required, while \c EventsID is
220 only necessary when your object has signals. To generate these identifiers,
221 use system tools like \c uuidgen or \c guidgen.
222
223 You can specify additional attributes for each of your classes; see
224 \l{Class Information and Tuning} for details.
225
226 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 5
227
228 Use the Q_PROPERTY() macro to declare properties for the ActiveX control.
229
230 Declare a standard constructor taking a parent object, and functions,
231 signals and slots like for any QObject subclass.
232 \footnote
233 If a standard constructor is not present the compiler will issue
234 an error "no overloaded function takes 2 parameters" when using
235 the default factory through the QAXFACTORY_DEFAULT() macro. If you
236 cannot provide a standard constructor you must implement a
237 QAxFactory custom factory and call the constructor you have in
238 your implementation of QAxFactory::create.
239 \endfootnote
240
241 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 6
242
243 The ActiveQt framework will expose properties and public slots as ActiveX
244 properties and methods, and signals as ActiveX events, and convert between
245 the Qt data types and the equivalent COM data types.
246
247 \section2 Data Types
248
249 The Qt data types that are supported for properties are:
250
251 \table
252 \header
253 \o Qt data type
254 \o COM property
255 \row
256 \o bool
257 \o VARIANT_BOOL
258 \row
259 \o QString
260 \o BSTR
261 \row
262 \o int
263 \o int
264 \row
265 \o uint
266 \o unsigned int
267 \row
268 \o double
269 \o double
270 \row
271 \o \l qlonglong
272 \o CY
273 \row
274 \o \l qulonglong
275 \o CY
276 \row
277 \o QColor
278 \o OLE_COLOR
279 \row
280 \o QDate
281 \o DATE
282 \row
283 \o QDateTime
284 \o DATE
285 \row
286 \o QTime
287 \o DATE
288 \row
289 \o QFont
290 \o IFontDisp*
291 \row
292 \o QPixmap
293 \o IPictureDisp*
294 \footnote
295 COM cannot marshal IPictureDisp accross process boundaries,
296 so QPixmap properties cannot be called for out-of-process servers. You
297 can however marshal the image data via e.g. temporary files. See the
298 Microsoft
299 \link http://support.microsoft.com/default.aspx?scid=kb;[LN];Q150034 KB article
300 Q150034 \endlink for more information.
301 \endfootnote
302 \row
303 \o QVariant
304 \o VARIANT
305 \row
306 \o QVariantList (same as QList\<QVariant\>)
307 \o SAFEARRAY(VARIANT)
308 \row
309 \o QStringList
310 \o SAFEARRAY(BSTR)
311 \row
312 \o QByteArray
313 \o SAFEARRAY(BYTE)
314 \row
315 \o QRect
316 \o User defined type
317 \row
318 \o QSize
319 \o User defined type
320 \row
321 \o QPoint
322 \o User defined type
323 \endtable
324
325 The Qt data types that are supported for parameters in signals and
326 slots are:
327 \table
328 \header
329 \o Qt data type
330 \o COM parameter
331 \row
332 \o bool
333 \o [in] VARIANT_BOOL
334 \row
335 \o bool&
336 \o [in, out] VARIANT_BOOL*
337 \row
338 \o QString, const QString&
339 \o [in] BSTR
340 \row
341 \o QString&
342 \o [in, out] BSTR*
343 \row
344 \o QString&
345 \o [in, out] BSTR*
346 \row
347 \o int
348 \o [in] int
349 \row
350 \o int&
351 \o [in,out] int
352 \row
353 \o uint
354 \o [in] unsigned int
355 \row
356 \o uint&
357 \o [in, out] unsigned int*
358 \row
359 \o double
360 \o [in] double
361 \row
362 \o double&
363 \o [in, out] double*
364 \row
365 \o QColor, const QColor&
366 \o [in] OLE_COLOR
367 \row
368 \o QColor&
369 \o [in, out] OLE_COLOR*
370 \row
371 \o QDate, const QDate&
372 \o [in] DATE
373 \row
374 \o QDate&
375 \o [in, out] DATE*
376 \row
377 \o QDateTime, const QDateTime&
378 \o [in] DATE
379 \row
380 \o QDateTime&
381 \o [in, out] DATE*
382 \row
383 \o QFont, const QFont&
384 \o [in] IFontDisp*
385 \row
386 \o QFont&
387 \o [in, out] IFontDisp**
388 \row
389 \o QPixmap, const QPixmap&
390 \o [in] IPictureDisp*
391 \row
392 \o QPixmap&
393 \o [in, out] IPictureDisp**
394 \row
395 \o QList\<QVariant\>, const QList\<QVariant\>&
396 \o [in] SAFEARRAY(VARIANT)
397 \row
398 \o QList\<QVariant\>&
399 \o [in, out] SAFEARRAY(VARIANT)*
400 \row
401 \o QStringList, const QStringList&
402 \o [in] SAFEARRAY(BSTR)
403 \row
404 \o QStringList&
405 \o [in, out] SAFEARRAY(BSTR)*
406 \row
407 \o QByteArray, const QByteArray&
408 \o [in] SAFEARRAY(BYTE)
409 \row
410 \o QByteArray&
411 \o [in, out] SAFEARRAY(BYTE)*
412 \row
413 \o QObject*
414 \o [in] IDispatch*
415 \row
416 \o QRect&
417 \footnote
418 OLE needs to marshal user defined types by reference (ByRef), and cannot
419 marshal them by value (ByVal). This is why const-references and object
420 parameters are not supported for QRect, QSize and QPoint. Also note that
421 servers with this datatype require Windows 98 or DCOM 1.2 to be installed.
422 \endfootnote
423 \o [in, out] struct QRect (user defined)
424 \row
425 \o QSize&
426 \o [in, out] struct QSize (user defined)
427 \row
428 \o QPoint&
429 \o [in, out] struct QPoint (user defined)
430 \endtable
431
432 Also supported are exported enums and flags (see Q_ENUMS() and
433 Q_FLAGS()). The in-parameter types are also supported as
434 return values.
435
436 Properties and signals/slots that have parameters using any other
437 data types are ignored by the ActiveQt framework.
438
439 \section2 Sub-Objects
440
441 COM objects can have multiple sub-objects that can represent a sub element
442 of the COM object. A COM object representing a multi-document spread sheet
443 application can for example provide one sub-object for each spread sheet.
444
445 Any QObject subclass can be used as the type for a sub object in ActiveX, as
446 long as it is known to the QAxFactory. Then the type can be used in properties,
447 or as the return type or paramter of a slot.
448
449 \section2 Property Notification
450
451 To make the properties bindable for the ActiveX client, use multiple
452 inheritance from the QAxBindable class:
453
454 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 7
455
456 When implementing the property write functions, use the
457 QAxBindable class's requestPropertyChange() and propertyChanged()
458 functions to allow ActiveX clients to bind to the control
459 properties.
460 \footnote
461 This is not required, but gives the client more control over
462 the ActiveX control.
463 \endfootnote
464
465 \section1 Serving Controls
466
467 To make a COM server available to the COM system it must be registered
468 in the system registry using five unique identifiers.
469 These identifiers are provided by tools like \c guidgen or \c uuidgen.
470 The registration information allows COM to localize the binary providing
471 a requested ActiveX control, marshall remote procedure calls to the
472 control and read type information about the methods and properties exposed
473 by the control.
474
475 To create the COM object when the client asks for it the server must export
476 an implementation of a QAxFactory. The easist way to do this is to use a set
477 of macros:
478
479 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 8
480
481 This will export \c MyWidget and \c MyWidget2 as COM objects that can be
482 created by COM clients, and will register \c MySubType as a type that can
483 be used in properties and parameters of \c MyWidget and \c MyWidget2.
484
485 The \link QAxFactory QAxFactory class documentation \endlink explains
486 how to use this macro, and how to implement and use custom factories.
487
488 For out-of-process executable servers you can implement a main()
489 function to instantiate a QApplication object and enter the event
490 loop just like any normal Qt application. By default the
491 application will start as a standard Qt application, but if you
492 pass \c -activex on the command line it will start as an ActiveX
493 server. Use QAxFactory::isServer() to create and run a standard
494 application interface, or to prevent a stand-alone execution:
495
496 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 9
497
498 This is however not necessary as ActiveQt provides a default implementation
499 of a main function. The default implemenation calls QAxFactory::startServer(),
500 creates a QApplication instance and calls exec().
501
502 To build the ActiveX server executable run \c qmake
503 to generate the makefile, and use your compiler's
504 make tool as for any other Qt application. The make process will
505 also register the controls in the system registry by calling the
506 resulting executable with the \c -regserver command line option.
507
508 If the ActiveX server is an executable, the following command line
509 options are supported:
510 \table
511 \header \o Option \o Result
512 \row \o \c -regserver \o Registers the server in the system registry
513 \row \o \c -unregserver \o Unregisters the server from the system registry
514 \row \o \c -activex \o Starts the application as an ActiveX server
515 \row \o \c{-dumpidl <file> -version x.y} \o Writes the server's IDL to the
516 specified file. The type library will have version x.y
517 \endtable
518
519 In-process servers can be registered using the \c regsvr32 tool available
520 on all Windows systems.
521
522 \section2 Typical Compile-Time Problems
523
524 The compiler/linker errors listed are based on those issued by the
525 Microsoft Visual C++ 6.0 compiler.
526
527 \section3 "No overloaded function takes 2 parameters"
528
529 When the error occurs in code that uses the QAXFACTORY_DEFAULT()
530 macro, the widget class had no constructor that can be used by the
531 default factory. Either add a standard widget constructor or
532 implement a custom factory that doesn't require one.
533
534 When the error occurs in code that uses the QAXFACTORY_EXPORT()
535 macro, the QAxFactory subclass had no appropriate constructor.
536 Provide a public class constructor like
537
538 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 10
539
540 for your factory class.
541
542 \section3 "Syntax error: bad suffix on number"
543
544 The unique identifiers have not been passed as strings into the
545 QAXFACTORY_EXPORT() or QAXFACTORY_DEFAULT() macro.
546
547 \section3 "Unresolved external symbol _ucm_instantiate"
548
549 The server does not export an implementation of a QAxFactory. Use
550 the QAXFACTORY_EXPORT() macro in one of the project's
551 implementation files to instantiate and export a factory, or use
552 the QAXFACTORY_DEFAULT() macro to use the default factory.
553
554 \section3 "_ucm_initialize already defined in ..."
555
556 The server exports more than one implementation of a QAxFactory,
557 or exports the same implementation twice. If you use the default
558 factory, the QAXFACTORY_DEFAULT() macro must only be used once in
559 the project. Use a custom QAxFactory implementation and the
560 QAXFACTORY_EXPORT() macro if the server provides multiple ActiveX
561 controls.
562
563 \section2 Distributing QAxServer Binaries
564
565 ActiveX servers written with Qt can use Qt either as a shared
566 library, or have Qt linked statically into the binary. Both ways
567 will produce rather large packages (either the server binary
568 itself becomes large, or you have to ship the Qt DLL).
569
570 \section3 Installing Stand-Alone Servers
571
572 When your ActiveX server can also run as a stand-alone application,
573 run the server executable with the \c -regserver command line
574 parameter after installing the executable on the target system.
575 After that the controls provided by the server will be available to
576 ActiveX clients.
577
578 \section3 Installing In-Process Servers
579
580 When your ActiveX server is part of an installation package, use the
581 \c regsvr32 tool provided by Microsoft to register the controls on
582 the target system. If this tool is not present, load the DLL into
583 your installer process, resolve the \c DllRegisterServer symbol and
584 call the function:
585
586 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 11
587
588 \section3 Distributing Servers over the Internet
589
590 If you want to use controls in your server in web-pages you need to
591 make the server available to the browser used to view your page, and
592 you need to specify the location of the server package in your page.
593
594 To specify the location of a server, use the CODEBASE attribute in
595 the OBJECT tag of your web-site. The value can point to the server
596 file itself, to an INF file listing other files the server requires
597 (e.g. the Qt DLL), or a compressed CAB archive.
598
599 INF and CAB files are documented in almost every book available about
600 ActiveX and COM programming as well as in the MSDN library and various
601 other Online resources. The examples include INF files that can be used
602 to build CAB archives:
603
604 \snippet examples/activeqt/simple/simple.inf 0
605
606 The CABARC tool from Microsoft can easily generate CAB archives:
607
608 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 12
609
610 The INF files assume a static build of Qt, so no dependencies to other DLLs
611 are listed in the INF files. To distribute an ActiveX server depending on
612 DLLs you must add the dependencies, and provide the library files
613 with the archive.
614
615 \section1 Using the Controls
616
617 To use the ActiveX controls, e.g. to embed them in a web page, use
618 the \c <object> HTML tag.
619
620 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 13
621
622 To initialize the control's properties, use
623
624 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 14
625
626 If the web browser supports scripting use JavaScript, VBScript
627 and forms to script the control. The
628 \l{Qt Examples#ActiveQt}{ActiveQt examples} include demonstration
629 HTML pages for the example controls.
630
631 \section2 Supported and Unsupported ActiveX Clients
632
633 The following is largly based on our own experiements with ActiveX
634 controls and client applications, and is by no means complete.
635
636 \section3 Supported Clients
637
638 These standard applications work with ActiveX controls developed with
639 ActiveQt. Note that some clients support only in-process controls.
640
641 \list
642 \o Internet Explorer
643 \o Microsoft ActiveX Control Test Container
644 \o Microsoft Visual Studio 6.0
645 \o Microsoft Visual Studio.NET/2003
646 \o Microsoft Visual Basic 6.0
647 \o MFC- and ATL-based containers
648 \o Sybase PowerBuilder
649 \o ActiveQt based containers
650 \endlist
651
652 Microsoft Office applications are supported, but you need to register
653 the controls as "Insertable" objects. Reimplement QAxFactory::registerClass
654 to add this attribute to the COM class, or set the "Insertable" class info
655 for your class to "yes" using the Q_CLASSINFO macro.
656
657 \section3 Unsupported Clients
658
659 We have not managed to make ActiveQt based COM objects work with the
660 following client applications.
661
662 \list
663 \o Borland C++ Builder (Versions 5 and 6)
664 \o Borland Delphi
665 \endlist
666
667 \section2 Typical Runtime Errors
668
669 \section3 The Server Does Not Respond
670
671 If the system is unable to start the server (check with the task
672 manager whether the server runs a process), make sure that no DLL
673 the server depends on is missing from the system path (e.g. the Qt
674 DLL!). Use a dependency walker to view all dependencies of the server
675 binary.
676
677 If the server runs (e.g. the task manager lists a process), see
678 the following section for information on debugging your server.
679
680 \section3 The Object Cannot Be Created
681
682 If the server could be built and registered correctly during the build
683 process, but the object cannot be initiliazed e.g. by the OLE/COM Object
684 Viewer application, make sure that no DLL the server depends on is
685 missing from the system path (e.g. the Qt DLL). Use a dependency walker
686 to view all dependencies of the server binary.
687
688 If the server runs, see the following section for information on
689 debugging your server.
690
691 \section2 Debugging Runtime Errors
692
693 To debug an in-process server in Visual Studio, set the server project
694 as the active project, and specify a client "executable for debug
695 session" in the project settings (e.g. use the ActiveX Test Container).
696 You can set breakpoints in your code, and also step into ActiveQt and
697 Qt code if you installed the debug version.
698
699 To debug an executable server, run the application in a debugger
700 and start with the command line parameter \c -activex. Then start
701 your client and create an instance of your ActiveX control. COM
702 will use the existing process for the next client trying to create
703 an ActiveX control.
704
705 \section1 Class Information and Tuning
706
707 To provide attributes for each COM class, use the Q_CLASSINFO macro, which is part of
708 Qt's meta object system.
709
710 \table
711 \header
712 \o Key
713 \o Meaning of value
714 \row
715 \o Version
716 \o The version of the class (1.0 is default)
717 \row
718 \o Description
719 \o A string describing the class.
720 \row
721 \o ClassID
722 \o The class ID.
723 You must reimplement QAxFactory::classID if not specified.
724 \row
725 \o InterfaceID
726 \o The interface ID.
727 You must reimplement QAxFactory::interfaceID if not specified.
728 \row
729 \o EventsID
730 \o The event interface ID.
731 No signals are exposed as COM events if not specified.
732 \row
733 \o DefaultProperty
734 \o The property specified represents the default property of this class.
735 Ie. the default property of a push button would be "text".
736 \row
737 \o DefaultSignal
738 \o The signal specified respresents the default signal of this class.
739 Ie. the default signal of a push button would be "clicked".
740 \row
741 \o LicenseKey
742 \o Object creation requires the specified license key. The key can be
743 empty to require a licensed machine. By default classes are not
744 licensed. Also see the following section.
745 \row
746 \o StockEvents
747 \o Objects expose stock events if value is "yes".
748 See \l QAxFactory::hasStockEvents()
749 \row
750 \o ToSuperClass
751 \o Objects expose functionality of all super-classes up to and
752 including the class name in value.
753 See \l QAxFactory::exposeToSuperClass()
754 \row
755 \o Insertable
756 \o If the value is "yes" the class is registered to be "Insertable"
757 and will be listed in OLE 2 containers (ie. Microsoft Office). This
758 attribute is not be set by default.
759 \row
760 \o Aggregatable
761 \o If the value is "no" the class does not support aggregation. By
762 default aggregation is supported.
763 \row
764 \o Creatable
765 \o If the value is "no" the class cannot be created by the client,
766 and is only available through the API of another class (ie. the
767 class is a sub-type).
768 \row
769 \o RegisterObject
770 \o If the value is "yes" objects of this class are registered with
771 OLE and accessible from the running object table (ie. clients
772 can connect to an already running instance of this class). This
773 attribute is only supported in out-of-process servers.
774 \row
775 \o MIME
776 \o The object can handle data and files of the format specified in the
777 value. The value has the format mime:extension:description. Multiple
778 formats are separated by a semicolon.
779 \row
780 \o CoClassAlias
781 \o The classname used in the generated IDL and in the registry. This is
782 esp. useful for C++ classes that live in a namespace - by default,
783 ActiveQt just removes the "::" to make the IDL compile.
784 \endtable
785
786 Note that both keys and values are case sensitive.
787
788 The following declares version 2.0 of a class that exposes only its
789 own API, and is available in the "Insert Objects" dialog of Microsoft
790 Office applications.
791
792 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 15
793
794 \section2 Developing Licensed Components
795
796 If you develop components you might want to control who is able to instantiate
797 those components. Since the server binary can be shipped to and registered on
798 any client machine it is possible for anybody to use those components in his
799 own software.
800
801 Licensing components can be done using a variety of techniques, e.g. the code
802 creating the control can provide a license key, or the machine on which the
803 control is supposed to run needs to be licensed.
804
805 To mark a Qt class as licensed specify a "LicenseKey" using the
806 Q_CLASSINFO() macro.
807
808 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 16
809
810 The key is required to be able to create an instance of \c MyLicensedControl
811 on a machine that is not licensed itself. The licensed developer can now
812 redistributes the server binary with his application, which creates the control
813 using the value of "LicenseKey", while users of the application cannot create
814 the control without the license key.
815
816 If a single license key for the control is not sufficient (ie. you want
817 differnet developers to receive different license keys) you can specify an
818 empty key to indicate that the control requires a license, and reimplement
819 \l QAxFactory::validateLicenseKey() to verify that a license exists on the
820 system (ie. through a license file).
821
822 \section2 More Interfaces
823
824 ActiveX controls provided by ActiveQt servers support a minimal set of COM
825 interfaces to implement the OLE specifications. When the ActiveX class inherits
826 from the QAxBindable class it can also implement additional COM interfaces.
827
828 Create a new subclass of QAxAggregated and use multiple inheritance
829 to subclass additional COM interface classes.
830
831 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 17
832
833 Reimplement the QAxAggregated::queryInterface() function to
834 support the additional COM interfaces.
835
836 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 18
837
838 Since \c ISomeCOMInterface is a subclass of \c IUnknown you will
839 have to implement the \c QueryInterface(), \c AddRef(), and \c
840 Release() functions. Use the QAXAGG_IUNKNOWN macro in your
841 class definition to do that. If you implement the \c IUnknown
842 functions manually, delegate the calls to the interface pointer
843 returned by the QAxAggregated::controllingUnknown() function,
844 e.g.
845
846 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 19
847
848 Do not support the \c IUnknown interface itself in your
849 \l{QAxAggregated::queryInterface()}{queryInterface()}
850 implementation.
851
852 Implement the methods of the COM interfaces, and use QAxAggregated::object()
853 if you need to make calls to the QObject subclass implementing the control.
854
855 In your QAxBindable subclass, implement
856 QAxBindable::createAggregate() to return a new object of the
857 QAxAggregated subclass.
858
859 \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 20
860
861 \section1 License Information
862
863 The QAxContainer module is not covered by the \l{GNU General Public License (GPL)},
864 the \l{GNU Lesser General Public License (LGPL)}, or the
865 \l{Qt Commercial Editions}{Qt Commercial License}. Instead, it is distributed under
866 the following license.
867
868 \legalese
869 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).\br
870 All rights reserved.
871
872 Contact: Qt Software Information ([email protected])\br
873
874 You may use this file under the terms of the BSD license as follows:\br
875
876 "Redistribution and use in source and binary forms, with or without modification,
877 are permitted provided that the following conditions are met:
878
879 * Redistributions of source code must retain the above copyright notice, this list
880 of conditions and the following disclaimer.\br
881 * Redistributions in binary form must reproduce the above copyright notice, this
882 list of conditions and the following disclaimer in the documentation and/or other
883 materials provided with the distribution.\br
884 * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor the names of
885 its contributors may be used to endorse or promote products derived from this
886 software without specific prior written permission.
887
888 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
889 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
890 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
891 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
892 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
893 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
894 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
895 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
896 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
897 \endlegalese
898*/
Note: See TracBrowser for help on using the repository browser.