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.html150
1 files changed, 75 insertions, 75 deletions
diff --git a/doc/html/designer-manual-7.html b/doc/html/designer-manual-7.html
index 5f28e2d8d..50d7f36b4 100644
--- a/doc/html/designer-manual-7.html
+++ b/doc/html/designer-manual-7.html
@@ -39,15 +39,15 @@ body { background: #ffffff; color: black; }
<!-- index Custom Widgets!Simple --><p>There are two stages to creating a custom widget. Firstly we must create a class that defines the widget, and secondly we must incorporate the widget into <em>TQt Designer</em>. Creating the widget has to be done whether we are creating a simple custom widget or a plugin, but for simple custom widgets the incorporation into <em>TQt Designer</em> is very easy.</p>
<p>We will create a VCR style widget comprising four buttons, rewind, play, next and stop. The widget will emit signals according to which button is clicked.</p>
<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="qpushbutton.html">TQPushButton</a> widgets to form the basis of our custom widget.</p>
+<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">qwidget.h</a>&gt;
+<pre> #include &lt;<a href="qwidget-h.html">ntqwidget.h</a>&gt;
- class Vcr : public <a href="qwidget.html">TQWidget</a>
+ class Vcr : public <a href="ntqwidget.html">TQWidget</a>
{
Q_OBJECT
public:
- Vcr( <a href="qwidget.html">TQWidget</a> *parent = 0, const char *name = 0 );
+ Vcr( <a href="ntqwidget.html">TQWidget</a> *parent = 0, const char *name = 0 );
~Vcr() {}
signals:
void rewind();
@@ -56,19 +56,19 @@ body { background: #ffffff; color: black; }
void stop();
};
</pre>
-<!-- index Macros!Q_OBJECT --><!-- index Q_OBJECT --> <p>We include <tt>qwidget.h</tt> since we'll be deriving our custom widget from <a href="qwidget.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!Q_OBJECT --><!-- index Q_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>
<p><b>Note:</b> Since we're using signals we must also include the <tt>Q_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="qwidget.html">TQWidget</a> *parent, const char *name )
- : <a href="qwidget.html">TQWidget</a>( parent, name )
+<pre> Vcr::Vcr( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name )
+ : <a href="ntqwidget.html">TQWidget</a>( parent, name )
{
<a href="qhboxlayout.html">TQHBoxLayout</a> *layout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( this );
- layout-&gt;<a href="qlayout.html#setMargin">setMargin</a>( 0 );
+ layout-&gt;<a href="ntqlayout.html#setMargin">setMargin</a>( 0 );
- <a href="qpushbutton.html">TQPushButton</a> *rewind = new <a href="qpushbutton.html">TQPushButton</a>( TQPixmap( rewind_xpm ), 0, this, "vcr_rewind" );
+ <a href="ntqpushbutton.html">TQPushButton</a> *rewind = new <a href="ntqpushbutton.html">TQPushButton</a>( TQPixmap( rewind_xpm ), 0, this, "vcr_rewind" );
layout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( rewind );
</pre>
- <p>We create a <a href="qhboxlayout.html">TQHBoxLayout</a> in which we'll place the buttons. We've only shown the rewind button in the code above since all the others are identical except for the names of the buttons, pixmaps and signals. For each of the buttons we require we call the <a href="qpushbutton.html">TQPushButton</a> constructor passing it the appropriate embedded pixmap. We then add it to the layout. Finally we connect the button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate <em>signal</em>. Since the<!-- index clicked() --> <tt>clicked()</tt> signals aren't specific to our widget we want to emit signals that reflect the widget's use. The <tt>rewind()</tt>, <tt>play()</tt>, etc. signals are meaningful in the context of our widget so we propagate each button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate widget-specific signal.</p>
+ <p>We create a <a href="qhboxlayout.html">TQHBoxLayout</a> in which we'll place the buttons. We've only shown the rewind button in the code above since all the others are identical except for the names of the buttons, pixmaps and signals. For each of the buttons we require we call the <a href="ntqpushbutton.html">TQPushButton</a> constructor passing it the appropriate embedded pixmap. We then add it to the layout. Finally we connect the button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate <em>signal</em>. Since the<!-- index clicked() --> <tt>clicked()</tt> signals aren't specific to our widget we want to emit signals that reflect the widget's use. The <tt>rewind()</tt>, <tt>play()</tt>, etc. signals are meaningful in the context of our widget so we propagate each button's<!-- index clicked() --> <tt>clicked()</tt> signal to the appropriate widget-specific signal.</p>
<!-- index Forms!Creating Test Harnesses --><p>The implementation is complete, but to make sure that our widget compiles and runs we'll create a tiny test harness. The test harness will require two files, a<!-- index .pro --> <tt>.pro</tt> project file and a<!-- index main.cpp --> <tt>main.cpp</tt>. The <tt>qt/tools/designer/examples/vcr/vcr.pro</tt> project file:</p>
<pre>TEMPLATE = app
LANGUAGE = C++
@@ -80,15 +80,15 @@ HEADERS += vcr.h
DBFILE = vcr.db
</pre>
<p>The <tt>qt/tools/designer/examples/vcr/main.cpp</tt> file is also brief:</p>
-<pre> #include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
+<pre> #include &lt;<a href="qapplication-h.html">ntqapplication.h</a>&gt;
#include "vcr.h"
int main( int argc, char ** argv )
{
- <a href="qapplication.html">TQApplication</a> app( argc, argv );
+ <a href="ntqapplication.html">TQApplication</a> app( argc, argv );
Vcr *vcr = new Vcr;
- vcr-&gt;<a href="qwidget.html#show">show</a>();
- return app.<a href="qapplication.html#exec">exec</a>();
+ vcr-&gt;<a href="ntqwidget.html#show">show</a>();
+ return app.<a href="ntqapplication.html#exec">exec</a>();
}
</pre>
<p>Once we're satisfied that the custom widget compiles and runs we are ready to incorporate it into <em>TQt Designer</em>.</p>
@@ -113,23 +113,23 @@ DBFILE = vcr.db
<!-- index Properties!Creating Custom Properties --><p>We have two recommendations that you should consider when creating a custom widget for a plugin:</p>
<ol type=1><li><p>Using TQt's property system will provide <em>TQt Designer</em> users with a direct means of configuring the widget through the property editor. (See the <a href="http://doc.trolltech.com/properties.html">TQt Properties</a> documentation.)</p>
<li><p>Consider making your widget's public 'set' functions into public slots so that you can perform signal-slot connections with the widget in <em>TQt Designer</em>.</p>
-</ol><p>In the course of this chapter we will create a simple but useful widget, 'FileChooser', which we'll later make available in <em>TQt Designer</em> as a plugin. In practice most custom widgets are created to add functionality rather than to compose widgets, so we will create our widget in code rather than using <em>TQt Designer</em> to reflect this approach. FileChooser consists of a <a href="qlineedit.html">TQLineEdit</a> and a <a href="qpushbutton.html">TQPushButton</a>. The <a href="qlineedit.html">TQLineEdit</a> is used to hold a file or directory name, the <a href="qpushbutton.html">TQPushButton</a> is used to launch a file dialog through which the user can choose a file or directory.</p>
+</ol><p>In the course of this chapter we will create a simple but useful widget, 'FileChooser', which we'll later make available in <em>TQt Designer</em> as a plugin. In practice most custom widgets are created to add functionality rather than to compose widgets, so we will create our widget in code rather than using <em>TQt Designer</em> to reflect this approach. FileChooser consists of a <a href="ntqlineedit.html">TQLineEdit</a> and a <a href="ntqpushbutton.html">TQPushButton</a>. The <a href="ntqlineedit.html">TQLineEdit</a> is used to hold a file or directory name, the <a href="ntqpushbutton.html">TQPushButton</a> is used to launch a file dialog through which the user can choose a file or directory.</p>
<p align="center"><img align="middle" src="filechooser.png" width="169" height="34">
</p>
<blockquote><p align="center"><em>The FileChooser Custom Widget</em></p></blockquote>
<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">qwidget.h</a>&gt;
- #include &lt;<a href="qwidgetplugin-h.html">qwidgetplugin.h</a>&gt;
+<pre> #include &lt;<a href="qwidget-h.html">ntqwidget.h</a>&gt;
+ #include &lt;<a href="qwidgetplugin-h.html">ntqwidgetplugin.h</a>&gt;
class TQLineEdit;
class TQPushButton;
</pre>
- <p>Our widget will be derived from <a href="qwidget.html">TQWidget</a> so we include the <tt>qwidget.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="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>
<pre></pre>
<!-- index Macros!Q_OBJECT --><!-- index Q_OBJECT --><!-- index Macros!Q_ENUMS --><!-- index Q_ENUMS --> <p>We include the <tt>Q_OBJECT</tt> macro since this is required for classes that declare signals or slots. The <tt>Q_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="qwidget.html">TQWidget</a>
+<pre> class QT_WIDGET_PLUGIN_EXPORT FileChooser : public <a href="ntqwidget.html">TQWidget</a>
{
Q_OBJECT
@@ -138,100 +138,100 @@ DBFILE = vcr.db
Q_PROPERTY( TQString fileName READ fileName WRITE setFileName )
public:
- FileChooser( <a href="qwidget.html">TQWidget</a> *parent = 0, const char *name = 0);
+ FileChooser( <a href="ntqwidget.html">TQWidget</a> *parent = 0, const char *name = 0);
enum Mode { File, Directory };
- <a href="qstring.html">TQString</a> fileName() const;
+ <a href="ntqstring.html">TQString</a> fileName() const;
Mode mode() const;
</pre>
<p>The constructor is declared in the standard way for widgets. We declare two public functions, <tt>fileName()</tt> to return the filename, and <tt>mode()</tt> to return the mode.</p>
<pre> public slots:
- void setFileName( const <a href="qstring.html">TQString</a> &amp;fn );
+ void setFileName( const <a href="ntqstring.html">TQString</a> &amp;fn );
void setMode( Mode m );
signals:
- void fileNameChanged( const <a href="qstring.html">TQString</a> &amp; );
+ void fileNameChanged( const <a href="ntqstring.html">TQString</a> &amp; );
private slots:
void chooseFile();
</pre>
<p>The two 'set' functions are declared as public slots. <tt>setFileName()</tt> and <tt>setMode()</tt> set the filename and mode respectively. We declare a single signal, <tt>fileNameChanged()</tt>. The private slot, <tt>chooseFile()</tt> is called by the widget itself when its button is clicked.</p>
<pre> private:
- <a href="qlineedit.html">TQLineEdit</a> *lineEdit;
- <a href="qpushbutton.html">TQPushButton</a> *button;
+ <a href="ntqlineedit.html">TQLineEdit</a> *lineEdit;
+ <a href="ntqpushbutton.html">TQPushButton</a> *button;
Mode md;
};
</pre>
- <p>A pointer to <a href="qlineedit.html">TQLineEdit</a> and <a href="qpushbutton.html">TQPushButton</a>, as well as a Mode variable are held as private data.</p>
+ <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="qwidget.html">TQWidget</a> *parent, const char *name )
- : <a href="qwidget.html">TQWidget</a>( parent, name ), md( File )
+<pre> FileChooser::FileChooser( <a href="ntqwidget.html">TQWidget</a> *parent, const char *name )
+ : <a href="ntqwidget.html">TQWidget</a>( parent, name ), md( File )
{
</pre>
- <p>The constructor passes the parent and name to its superclass, <a href="qwidget.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="ntqwidget.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="qlayout.html#setMargin">setMargin</a>( 0 );
+ layout-&gt;<a href="ntqlayout.html#setMargin">setMargin</a>( 0 );
- lineEdit = new <a href="qlineedit.html">TQLineEdit</a>( this, "filechooser_lineedit" );
+ lineEdit = new <a href="ntqlineedit.html">TQLineEdit</a>( this, "filechooser_lineedit" );
layout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( lineEdit );
</pre>
- <p>We begin by creating a horizontal box layout (<a href="qhboxlayout.html">TQHBoxLayout</a>) and add a <a href="qlineedit.html">TQLineEdit</a> and a <a href="qpushbutton.html">TQPushButton</a> to it.</p>
-<pre> <a href="qobject.html#connect">connect</a>( lineEdit, SIGNAL( <a href="qlineedit.html#textChanged">textChanged</a>( const <a href="qstring.html">TQString</a> &amp; ) ),
- this, SIGNAL( fileNameChanged( const <a href="qstring.html">TQString</a> &amp; ) ) );
+ <p>We begin by creating a horizontal box layout (<a href="qhboxlayout.html">TQHBoxLayout</a>) and add a <a href="ntqlineedit.html">TQLineEdit</a> and a <a href="ntqpushbutton.html">TQPushButton</a> to it.</p>
+<pre> <a href="ntqobject.html#connect">connect</a>( lineEdit, SIGNAL( <a href="ntqlineedit.html#textChanged">textChanged</a>( const <a href="ntqstring.html">TQString</a> &amp; ) ),
+ this, SIGNAL( fileNameChanged( const <a href="ntqstring.html">TQString</a> &amp; ) ) );
- button = new <a href="qpushbutton.html">TQPushButton</a>( "...", this, "filechooser_button" );
- button-&gt;<a href="qwidget.html#setFixedWidth">setFixedWidth</a>( button-&gt;<a href="qwidget.html#fontMetrics">fontMetrics</a>().width( " ... " ) );
+ 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( " ... " ) );
layout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( button );
- <a href="qobject.html#connect">connect</a>( button, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ),
+ <a href="ntqobject.html#connect">connect</a>( button, SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ),
this, 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="qlineedit.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="qwidget.html#setFocusProxy">setFocusProxy</a>( lineEdit );
+ <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>
<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>
-<pre> void FileChooser::setFileName( const <a href="qstring.html">TQString</a> &amp;fn )
+<pre> void FileChooser::setFileName( const <a href="ntqstring.html">TQString</a> &amp;fn )
{
- lineEdit-&gt;<a href="qlineedit.html#setText">setText</a>( fn );
+ lineEdit-&gt;<a href="ntqlineedit.html#setText">setText</a>( fn );
}
TQString FileChooser::fileName() const
{
- return lineEdit-&gt;<a href="qlineedit.html#text">text</a>();
+ return lineEdit-&gt;<a href="ntqlineedit.html#text">text</a>();
}
</pre>
- <p>The <tt>setFileName()</tt> function sets the filename in the <a href="qlineedit.html">TQLineEdit</a>, and the <tt>fileName()</tt> function returns the filename from the <a href="qlineedit.html">TQLineEdit</a>. The <tt>setMode()</tt> and <tt>mode()</tt> functions (not shown) are similarly set and return the given mode.</p>
+ <p>The <tt>setFileName()</tt> function sets the filename in the <a href="ntqlineedit.html">TQLineEdit</a>, and the <tt>fileName()</tt> function returns the filename from the <a href="ntqlineedit.html">TQLineEdit</a>. The <tt>setMode()</tt> and <tt>mode()</tt> functions (not shown) are similarly set and return the given mode.</p>
<pre> void FileChooser::chooseFile()
{
- <a href="qstring.html">TQString</a> fn;
+ <a href="ntqstring.html">TQString</a> fn;
if ( mode() == File )
- fn = TQFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( lineEdit-&gt;<a href="qlineedit.html#text">text</a>(), TQString::null, this );
+ fn = TQFileDialog::<a href="ntqfiledialog.html#getOpenFileName">getOpenFileName</a>( lineEdit-&gt;<a href="ntqlineedit.html#text">text</a>(), TQString::null, this );
else
- fn = TQFileDialog::<a href="qfiledialog.html#getExistingDirectory">getExistingDirectory</a>( lineEdit-&gt;<a href="qlineedit.html#text">text</a>(),this );
+ fn = TQFileDialog::<a href="ntqfiledialog.html#getExistingDirectory">getExistingDirectory</a>( lineEdit-&gt;<a href="ntqlineedit.html#text">text</a>(),this );
- if ( !fn.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
- lineEdit-&gt;<a href="qlineedit.html#setText">setText</a>( fn );
+ if ( !fn.<a href="ntqstring.html#isEmpty">isEmpty</a>() ) {
+ lineEdit-&gt;<a href="ntqlineedit.html#setText">setText</a>( fn );
emit fileNameChanged( fn );
}
}
</pre>
- <p>When <tt>chooseFile()</tt> is called it presents the user with a file or directory dialog depending on the mode. If the user chooses a file or directory the <a href="qlineedit.html">TQLineEdit</a> is updated with the chosen file or directory and the <tt>fileNameChanged()</tt> signal is emitted.</p>
+ <p>When <tt>chooseFile()</tt> is called it presents the user with a file or directory dialog depending on the mode. If the user chooses a file or directory the <a href="ntqlineedit.html">TQLineEdit</a> is updated with the chosen file or directory and the <tt>fileNameChanged()</tt> signal is emitted.</p>
<p>Although these two files complete the implementation of the FileChooser widget it is good practice to write a test harness to check that the widget behaves as expected before attempting to put it into a plugin.</p>
<h5><a name="2-1-3"></a>Testing the Implementation</h5>
<!-- index main.cpp --><!-- index Forms!Creating Test Harnesses --><p>We present a rudimentary test harness which will allow us to run our custom widget. The test harness requires two files, a <tt>main.cpp</tt> to contain the FileChooser, and a <tt>.pro</tt> file to create the Makefile from. Here is <tt>qt/tools/designer/examples/filechooser/widget/main.cpp</tt>:</p>
-<pre> #include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
+<pre> #include &lt;<a href="qapplication-h.html">ntqapplication.h</a>&gt;
#include "filechooser.h"
int main( int argc, char ** argv )
{
- <a href="qapplication.html">TQApplication</a> a( argc, argv );
+ <a href="ntqapplication.html">TQApplication</a> a( argc, argv );
FileChooser *fc = new FileChooser;
- fc-&gt;<a href="qwidget.html#show">show</a>();
- return a.<a href="qapplication.html#exec">exec</a>();
+ fc-&gt;<a href="ntqwidget.html#show">show</a>();
+ return a.<a href="ntqapplication.html#exec">exec</a>();
}
</pre>
<p>And here is <tt>qt/tools/designer/examples/filechooser/widget/filechooser.pro</tt></p>
@@ -248,25 +248,25 @@ 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="qwidgetplugin.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="ntqwidgetplugin.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">qwidgetplugin.h</a>&gt;
+<pre> #include &lt;<a href="qwidgetplugin-h.html">ntqwidgetplugin.h</a>&gt;
- class CustomWidgetPlugin : public <a href="qwidgetplugin.html">TQWidgetPlugin</a>
+ class CustomWidgetPlugin : public <a href="ntqwidgetplugin.html">TQWidgetPlugin</a>
{
public:
CustomWidgetPlugin();
- <a href="qstringlist.html">TQStringList</a> keys() const;
- <a href="qwidget.html">TQWidget</a>* create( const <a href="qstring.html">TQString</a> &amp;classname, TQWidget* parent = 0, const char* name = 0 );
- <a href="qstring.html">TQString</a> group( const <a href="qstring.html">TQString</a>&amp; ) const;
- <a href="qiconset.html">TQIconSet</a> iconSet( const <a href="qstring.html">TQString</a>&amp; ) const;
- <a href="qstring.html">TQString</a> includeFile( const <a href="qstring.html">TQString</a>&amp; ) const;
- <a href="qstring.html">TQString</a> toolTip( const <a href="qstring.html">TQString</a>&amp; ) const;
- <a href="qstring.html">TQString</a> whatsThis( const <a href="qstring.html">TQString</a>&amp; ) const;
- bool isContainer( const <a href="qstring.html">TQString</a>&amp; ) const;
+ <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="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;
+ <a href="ntqstring.html">TQString</a> toolTip( const <a href="ntqstring.html">TQString</a>&amp; ) const;
+ <a href="ntqstring.html">TQString</a> whatsThis( const <a href="ntqstring.html">TQString</a>&amp; ) const;
+ bool isContainer( const <a href="ntqstring.html">TQString</a>&amp; ) const;
};
</pre>
<blockquote><p align="center"><em>From <tt>qt/tools/designer/examples/filechooser/plugin/plugin.h</tt></em></p></blockquote>
@@ -280,16 +280,16 @@ 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="qwidgetplugin.html#keys">keys</a>() const
+<pre> TQStringList CustomWidgetPlugin::<a href="ntqwidgetplugin.html#keys">keys</a>() const
{
- <a href="qstringlist.html">TQStringList</a> list;
+ <a href="ntqstringlist.html">TQStringList</a> list;
list &lt;&lt; "FileChooser";
return list;
}
</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="qwidgetplugin.html#create">create</a>( const <a href="qstring.html">TQString</a> &amp;key, TQWidget* parent, const char* name )
+<pre> TQWidget* CustomWidgetPlugin::<a href="ntqwidgetplugin.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="qwidgetplugin.html#includeFile">includeFile</a>( const <a href="qstring.html">TQString</a>&amp; feature ) const
+<pre> TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.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="qwidgetplugin.html#group">group</a>( const <a href="qstring.html">TQString</a>&amp; feature ) const
+<pre> TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.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="qwidgetplugin.html#iconSet">iconSet</a>( const <a href="qstring.html">TQString</a>&amp; ) const
+ TQIconSet CustomWidgetPlugin::<a href="ntqwidgetplugin.html#iconSet">iconSet</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
{
return TQIconSet( TQPixmap( filechooser_pixmap ) );
}
- TQString CustomWidgetPlugin::<a href="qwidgetplugin.html#includeFile">includeFile</a>( const <a href="qstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.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="qwidgetplugin.html#toolTip">toolTip</a>( const <a href="qstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.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="qwidgetplugin.html#whatsThis">whatsThis</a>( const <a href="qstring.html">TQString</a>&amp; feature ) const
+ TQString CustomWidgetPlugin::<a href="ntqwidgetplugin.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,12 +343,12 @@ 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="qwidgetplugin.html#isContainer">isContainer</a>( const <a href="qstring.html">TQString</a>&amp; ) const
+<pre> bool CustomWidgetPlugin::<a href="ntqwidgetplugin.html#isContainer">isContainer</a>( const <a href="ntqstring.html">TQString</a>&amp; ) const
{
return FALSE;
}
</pre>
- <p>Copy this function changing the class name to suit your widget plugin implementation. It should return <tt>TRUE</tt> if your custom widget can contain other widgets, e.g. like <a href="qframe.html">TQFrame</a>, or <tt>FALSE</tt> if it must not contain other widgets, e.g. like <a href="qpushbutton.html">TQPushButton</a>.</p>
+ <p>Copy this function changing the class name to suit your widget plugin implementation. It should return <tt>TRUE</tt> if your custom widget can contain other widgets, e.g. like <a href="ntqframe.html">TQFrame</a>, or <tt>FALSE</tt> if it must not contain other widgets, e.g. like <a href="ntqpushbutton.html">TQPushButton</a>.</p>
<!-- index Macros!Q_EXPORT_PLUGIN --><!-- index Q_EXPORT_PLUGIN --><p>The <tt>Q_EXPORT_PLUGIN</tt> macro.</p>
<pre> Q_EXPORT_PLUGIN( CustomWidgetPlugin )
</pre>