summaryrefslogtreecommitdiffstats
path: root/doc/html/designer-manual-7.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/designer-manual-7.html')
-rw-r--r--doc/html/designer-manual-7.html62
1 files changed, 31 insertions, 31 deletions
diff --git a/doc/html/designer-manual-7.html b/doc/html/designer-manual-7.html
index c11dfc11c..d4320d300 100644
--- a/doc/html/designer-manual-7.html
+++ b/doc/html/designer-manual-7.html
@@ -41,13 +41,13 @@ body { background: #ffffff; color: black; }
<h4><a name="1-1"></a>Coding the Custom Widget</h4>
<p>A custom widget may consist of one or more standard widgets placed together in a particular combination, or may be written from scratch. We will combine some <a href="ntqpushbutton.html">TQPushButton</a> widgets to form the basis of our custom widget.</p>
<p>We'll look at the header file, <tt>qt/tools/designer/examples/vcr/vcr.h</tt> first.</p>
-<pre> #include &lt;<a href="qwidget-h.html">ntqwidget.h</a>&gt;
+<pre> #include &lt;<a href="tqwidget-h.html">tqwidget.h</a>&gt;
- class Vcr : public <a href="ntqwidget.html">TQWidget</a>
+ class Vcr : public <a href="tqwidget.html">TQWidget</a>
{
TQ_OBJECT
public:
- Vcr( <a href="ntqwidget.html">TQWidget</a> *parent = 0, const char *name = 0 );
+ Vcr( <a href="tqwidget.html">TQWidget</a> *parent = 0, const char *name = 0 );
~Vcr() {}
signals:
void rewind();
@@ -56,11 +56,11 @@ body { background: #ffffff; color: black; }
void stop();
};
</pre>
-<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT --> <p>We include <tt>ntqwidget.h</tt> since we'll be deriving our custom widget from <a href="ntqwidget.html">TQWidget</a>. We declare a constructor where the widget will be created and the four signals we want our widget to emit.</p>
+<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT --> <p>We include <tt>tqwidget.h</tt> since we'll be deriving our custom widget from <a href="tqwidget.html">TQWidget</a>. We declare a constructor where the widget will be created and the four signals we want our widget to emit.</p>
<p><b>Note:</b> Since we're using signals we must also include the <tt>TQ_OBJECT</tt> macro. This macro also ensures that information about the class is available via the <a href="metaobjects.html">Meta Object System</a> and ensures that <em>TQt Designer</em> will display the correct information about the widget.</p>
<p>The implementation is straightforward. The only function we implement is the constructor. The rest of the file consists of include statements and embedded<!-- index .xpm --> <tt>.xpm</tt> images.</p>
-<pre> Vcr::Vcr( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name )
- : <a href="ntqwidget.html">TQWidget</a>( parent, name )
+<pre> Vcr::Vcr( <a href="tqwidget.html">TQWidget</a> *parent, const char *name )
+ : <a href="tqwidget.html">TQWidget</a>( parent, name )
{
<a href="qhboxlayout.html">TQHBoxLayout</a> *layout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( this );
layout-&gt;<a href="ntqlayout.html#setMargin">setMargin</a>( 0 );
@@ -87,7 +87,7 @@ DBFILE = vcr.db
{
<a href="ntqapplication.html">TQApplication</a> app( argc, argv );
Vcr *vcr = new Vcr;
- vcr-&gt;<a href="ntqwidget.html#show">show</a>();
+ vcr-&gt;<a href="tqwidget.html#show">show</a>();
return app.<a href="ntqapplication.html#exec">exec</a>();
}
</pre>
@@ -120,16 +120,16 @@ DBFILE = vcr.db
<p>If you've followed the manual up to this point you may well be able to create this custom widget yourself. If you're confident that you can make your own version of the widget, or have another widget that you want to turn into a plugin, skip ahead to <a href="designer-manual-7.html#2-2">Creating a Plugin</a>. If you prefer to read how we created the widget then read on.</p>
<h5><a name="2-1-1"></a>Coding the Widget's Interface</h5>
<p>We will work step-by-step through the widget's header file, <tt>qt/tools/designer/examples/filechooser/widget/filechooser.h</tt>.</p>
-<pre> #include &lt;<a href="qwidget-h.html">ntqwidget.h</a>&gt;
- #include &lt;<a href="qwidgetplugin-h.html">ntqwidgetplugin.h</a>&gt;
+<pre> #include &lt;<a href="tqwidget-h.html">tqwidget.h</a>&gt;
+ #include &lt;<a href="tqwidgetplugin-h.html">tqwidgetplugin.h</a>&gt;
class TQLineEdit;
class TQPushButton;
</pre>
- <p>Our widget will be derived from <a href="ntqwidget.html">TQWidget</a> so we include the <tt>ntqwidget.h</tt> header file. We also forward declare the two classes that our widget will be built from.</p>
+ <p>Our widget will be derived from <a href="tqwidget.html">TQWidget</a> so we include the <tt>tqwidget.h</tt> header file. We also forward declare the two classes that our widget will be built from.</p>
<pre></pre>
<!-- index Macros!TQ_OBJECT --><!-- index TQ_OBJECT --><!-- index Macros!TQ_ENUMS --><!-- index TQ_ENUMS --> <p>We include the <tt>TQ_OBJECT</tt> macro since this is required for classes that declare signals or slots. The <tt>TQ_ENUMS</tt> declaration is used to register the Mode enumeration. Our widget has two properties, mode, to store whether the user should select a File or a Directory and fileName which stores the file or directory they chose.</p>
-<pre> class QT_WIDGET_PLUGIN_EXPORT FileChooser : public <a href="ntqwidget.html">TQWidget</a>
+<pre> class QT_WIDGET_PLUGIN_EXPORT FileChooser : public <a href="tqwidget.html">TQWidget</a>
{
TQ_OBJECT
@@ -138,7 +138,7 @@ DBFILE = vcr.db
TQ_PROPERTY( TQString fileName READ fileName WRITE setFileName )
public:
- FileChooser( <a href="ntqwidget.html">TQWidget</a> *parent = 0, const char *name = 0);
+ FileChooser( <a href="tqwidget.html">TQWidget</a> *parent = 0, const char *name = 0);
enum Mode { File, Directory };
@@ -167,11 +167,11 @@ DBFILE = vcr.db
<p>A pointer to <a href="ntqlineedit.html">TQLineEdit</a> and <a href="ntqpushbutton.html">TQPushButton</a>, as well as a Mode variable are held as private data.</p>
<h5><a name="2-1-2"></a>Coding the Implementation</h5>
<p>We will work step-by-step through the implementation which is in <tt>qt/tools/designer/examples/filechooser/widget/filechooser.cpp</tt>.</p>
-<pre> FileChooser::FileChooser( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name )
- : <a href="ntqwidget.html">TQWidget</a>( parent, name ), md( File )
+<pre> FileChooser::FileChooser( <a href="tqwidget.html">TQWidget</a> *parent, const char *name )
+ : <a href="tqwidget.html">TQWidget</a>( parent, name ), md( File )
{
</pre>
- <p>The constructor passes the parent and name to its superclass, <a href="ntqwidget.html">TQWidget</a>, and also initializes the private mode data, md, to File mode.</p>
+ <p>The constructor passes the parent and name to its superclass, <a href="tqwidget.html">TQWidget</a>, and also initializes the private mode data, md, to File mode.</p>
<pre> <a href="qhboxlayout.html">TQHBoxLayout</a> *layout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( this );
layout-&gt;<a href="ntqlayout.html#setMargin">setMargin</a>( 0 );
@@ -183,14 +183,14 @@ DBFILE = vcr.db
this, TQ_SIGNAL( fileNameChanged( const <a href="ntqstring.html">TQString</a> &amp; ) ) );
button = new <a href="ntqpushbutton.html">TQPushButton</a>( "...", this, "filechooser_button" );
- button-&gt;<a href="ntqwidget.html#setFixedWidth">setFixedWidth</a>( button-&gt;<a href="ntqwidget.html#fontMetrics">fontMetrics</a>().width( " ... " ) );
+ button-&gt;<a href="tqwidget.html#setFixedWidth">setFixedWidth</a>( button-&gt;<a href="tqwidget.html#fontMetrics">fontMetrics</a>().width( " ... " ) );
layout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( button );
<a href="tqobject.html#connect">connect</a>( button, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ),
this, TQ_SLOT( chooseFile() ) );
</pre>
<p>We connect the lineEdit's<!-- index textChanged() --> <tt>textChanged()</tt> signal to the custom widget's <tt>fileNameChanged()</tt> signal. This ensures that if the user changes the text in the <a href="ntqlineedit.html">TQLineEdit</a> this fact will be propagated via the custom widget's own signal. The button's<!-- index clicked() --> <tt>clicked()</tt> signal is connected to the custom widget's <tt>chooseFile()</tt> slot which invokes the appropriate dialog for the user to choose their file or directory.</p>
-<pre> <a href="ntqwidget.html#setFocusProxy">setFocusProxy</a>( lineEdit );
+<pre> <a href="tqwidget.html#setFocusProxy">setFocusProxy</a>( lineEdit );
}
</pre>
<p>We set the lineEdit as the focus proxy for our custom widget. This means that when the widget is given focus the focus actually goes to the lineEdit.</p>
@@ -230,7 +230,7 @@ DBFILE = vcr.db
{
<a href="ntqapplication.html">TQApplication</a> a( argc, argv );
FileChooser *fc = new FileChooser;
- fc-&gt;<a href="ntqwidget.html#show">show</a>();
+ fc-&gt;<a href="tqwidget.html#show">show</a>();
return a.<a href="ntqapplication.html#exec">exec</a>();
}
</pre>
@@ -248,19 +248,19 @@ DEFINES += FILECHOOSER_IS_WIDGET
<p>We can create the makefile using <tt>qmake</tt>: <tt>qmake -o Makefile filechooser.pro</tt>, then we can make and run the harness to test our new widget. Once we're satisfied that the custom widget is robust and has the behaviour we require we can embed it into a plugin.</p>
<h4><a name="2-2"></a>Creating a Plugin</h4>
<!-- index Creating Plugins --><!-- index Plugins!Creating a Plugin --><!-- index Component!Plugins --><p>TQt Plugins can be used to provide self-contained software components for TQt applications. TQt currently supports the creation of five kinds of plugins: codecs, image formats, database drivers, styles and custom widgets. In this section we will explain how to convert our filechooser custom widget into a <em>TQt Designer</em> custom widget plugin.</p>
-<p>A <em>TQt Designer</em> custom widget plugin is always derived from <a href="ntqwidgetplugin.html">TQWidgetPlugin</a>. The amout of code that needs to be written is minimal.</p>
+<p>A <em>TQt Designer</em> custom widget plugin is always derived from <a href="tqwidgetplugin.html">TQWidgetPlugin</a>. The amout of code that needs to be written is minimal.</p>
<p>To make your own plugin it is probably easiest to start by copying our example<!-- index plugin.h --> <tt>plugin.h</tt> and<!-- index plugin.cpp --> <tt>plugin.cpp</tt> files and changing 'CustomWidgetPlugin' to the name you wish to use for your widget plugin implementation class. Below we provide an introduction to the header file although it needs no changes beyond class renaming. The implementation file requires simple changes, mostly more class renaming; we will review each function in turn and explain what you need to do.</p>
<h5><a name="2-2-1"></a>The <b>CustomWidgetPlugin</b> Implementation</h5>
<p>We have called our header file<!-- index plugin.h --> <tt>plugin.h</tt> and we've called our plugin class <b>CustomWidgetPlugin</b> since we will be using our plugin class to wrap our custom widgets. We present the entire header file to give you an impression of the scope of the implementation required. Most of the functions require just a few lines of code.</p>
-<pre> #include &lt;<a href="qwidgetplugin-h.html">ntqwidgetplugin.h</a>&gt;
+<pre> #include &lt;<a href="tqwidgetplugin-h.html">tqwidgetplugin.h</a>&gt;
- class CustomWidgetPlugin : public <a href="ntqwidgetplugin.html">TQWidgetPlugin</a>
+ class CustomWidgetPlugin : public <a href="tqwidgetplugin.html">TQWidgetPlugin</a>
{
public:
CustomWidgetPlugin();
<a href="ntqstringlist.html">TQStringList</a> keys() const;
- <a href="ntqwidget.html">TQWidget</a>* create( const <a href="ntqstring.html">TQString</a> &amp;classname, TQWidget* parent = 0, const char* name = 0 );
+ <a href="tqwidget.html">TQWidget</a>* create( const <a href="ntqstring.html">TQString</a> &amp;classname, TQWidget* parent = 0, const char* name = 0 );
<a href="ntqstring.html">TQString</a> group( const <a href="ntqstring.html">TQString</a>&amp; ) const;
<a href="ntqiconset.html">TQIconSet</a> iconSet( const <a href="ntqstring.html">TQString</a>&amp; ) const;
<a href="ntqstring.html">TQString</a> includeFile( const <a href="ntqstring.html">TQString</a>&amp; ) const;
@@ -280,7 +280,7 @@ DEFINES += FILECHOOSER_IS_WIDGET
<p>The constructor does not have to do anything. Simply copy ours with the class name you wish to use for your widget plugin implementation.</p>
<p>No destructor is necessary.</p>
<!-- index keys() --><p>The <tt>keys</tt> function.</p>
-<pre> TQStringList CustomWidgetPlugin::<a href="ntqwidgetplugin.html#keys">keys</a>() const
+<pre> TQStringList CustomWidgetPlugin::<a href="tqwidgetplugin.html#keys">keys</a>() const
{
<a href="ntqstringlist.html">TQStringList</a> list;
list &lt;&lt; "FileChooser";
@@ -289,7 +289,7 @@ DEFINES += FILECHOOSER_IS_WIDGET
</pre>
<p>For each widget class that you want to wrap in the plugin implementation you should supply a key by which the class can be identified. This key <em>must</em> be your class's name, so in our example we add a single key, 'FileChooser'.</p>
<!-- index create() --><p>The <tt>create()</tt> function.</p>
-<pre> TQWidget* CustomWidgetPlugin::<a href="ntqwidgetplugin.html#create">create</a>( const <a href="ntqstring.html">TQString</a> &amp;key, TQWidget* parent, const char* name )
+<pre> TQWidget* CustomWidgetPlugin::<a href="tqwidgetplugin.html#create">create</a>( const <a href="ntqstring.html">TQString</a> &amp;key, TQWidget* parent, const char* name )
{
if ( key == "FileChooser" )
return new FileChooser( parent, name );
@@ -298,7 +298,7 @@ DEFINES += FILECHOOSER_IS_WIDGET
</pre>
<p>In this function we create an instance of the requested class and return a TQWidget pointer to the newly created widget. Copy this function changing the class name and the feature name and create an instance of your widget just as we've done here. (See the <a href="http://doc.trolltech.com/plugins.html">TQt Plugin documentation</a> for more information.)</p>
<!-- index includeFile() --><p>The <tt>includeFile()</tt> function.</p>
-<pre> TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.html#includeFile">includeFile</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
+<pre> TQString CustomWidgetPlugin::<a href="tqwidgetplugin.html#includeFile">includeFile</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
{
if ( feature == "FileChooser" )
return "filechooser.h";
@@ -307,33 +307,33 @@ DEFINES += FILECHOOSER_IS_WIDGET
</pre>
<p>This function returns the name of the include file for the custom widget. Copy this function changing the class name, key and include filename to suit your own custom widget.</p>
<!-- index group() --><!-- index iconSet() --><!-- index includeFile() --><!-- index toolTip() --><!-- index whatsThis() --><p>The <tt>group()</tt>, <tt>iconSet()</tt>, <tt>toolTip()</tt> and <tt>whatsThis()</tt> functions.</p>
-<pre> TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.html#group">group</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
+<pre> TQString CustomWidgetPlugin::<a href="tqwidgetplugin.html#group">group</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
{
if ( feature == "FileChooser" )
return "Input";
return TQString::null;
}
- TQIconSet CustomWidgetPlugin::<a href="ntqwidgetplugin.html#iconSet">iconSet</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
+ TQIconSet CustomWidgetPlugin::<a href="tqwidgetplugin.html#iconSet">iconSet</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
{
return TQIconSet( TQPixmap( filechooser_pixmap ) );
}
- TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.html#includeFile">includeFile</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="tqwidgetplugin.html#includeFile">includeFile</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
{
if ( feature == "FileChooser" )
return "filechooser.h";
return TQString::null;
}
- TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.html#toolTip">toolTip</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="tqwidgetplugin.html#toolTip">toolTip</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
{
if ( feature == "FileChooser" )
return "File Chooser Widget";
return TQString::null;
}
- TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.html#whatsThis">whatsThis</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="tqwidgetplugin.html#whatsThis">whatsThis</a>( const <a href="ntqstring.html">TQString</a>&amp; feature ) const
{
if ( feature == "FileChooser" )
return "A widget to choose a file or directory";
@@ -343,7 +343,7 @@ DEFINES += FILECHOOSER_IS_WIDGET
<p>We use the <tt>group()</tt> function to identify which <em>TQt Designer</em> toolbar group this custom widget should be part of. If we use a name that is not in use <em>TQt Designer</em> will create a new toolbar group with the given name. Copy this function, changing the class name, key and group name to suit your own widget plugin implementation.</p>
<p>The <tt>iconSet()</tt> function returns the pixmap to use in the toolbar to represent the custom widget. The <tt>toolTip()</tt> function returns the tooltip text and the <tt>whatsThis()</tt> function returns the Whats This text. Copy each of these functions changing the class name, key and the string you return to suit your own widget plugin implementation.</p>
<!-- index isContainer() --><p>The <tt>isContainer()</tt> function.</p>
-<pre> bool CustomWidgetPlugin::<a href="ntqwidgetplugin.html#isContainer">isContainer</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
+<pre> bool CustomWidgetPlugin::<a href="tqwidgetplugin.html#isContainer">isContainer</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
{
return FALSE;
}