summaryrefslogtreecommitdiffstats
path: root/doc/html/simple-application.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/simple-application.html')
-rw-r--r--doc/html/simple-application.html254
1 files changed, 127 insertions, 127 deletions
diff --git a/doc/html/simple-application.html b/doc/html/simple-application.html
index f9d0a045..fd1d669d 100644
--- a/doc/html/simple-application.html
+++ b/doc/html/simple-application.html
@@ -34,11 +34,11 @@ body { background: #ffffff; color: black; }
<p>
-<p> This walkthrough shows simple use of <a href="qmainwindow.html">TQMainWindow</a>, <a href="qmenubar.html">TQMenuBar</a>, <a href="qpopupmenu.html">TQPopupMenu</a>, <a href="qtoolbar.html">TQToolBar</a> and <a href="qstatusbar.html">TQStatusBar</a> - classes that every
+<p> This walkthrough shows simple use of <a href="ntqmainwindow.html">TQMainWindow</a>, <a href="ntqmenubar.html">TQMenuBar</a>, <a href="ntqpopupmenu.html">TQPopupMenu</a>, <a href="ntqtoolbar.html">TQToolBar</a> and <a href="ntqstatusbar.html">TQStatusBar</a> - classes that every
modern application window tends to use. (See also <a href="tutorial2.html">Tutorial #2</a>.)
-<p> It also illustrates some aspects of <a href="qwhatsthis.html">TQWhatsThis</a> (for simple help) and a
-typical <tt>main()</tt> using <a href="qapplication.html">TQApplication</a>.
-<p> Finally, it shows a typical print function based on <a href="qprinter.html">TQPrinter</a>.
+<p> It also illustrates some aspects of <a href="ntqwhatsthis.html">TQWhatsThis</a> (for simple help) and a
+typical <tt>main()</tt> using <a href="ntqapplication.html">TQApplication</a>.
+<p> Finally, it shows a typical print function based on <a href="ntqprinter.html">TQPrinter</a>.
<p> <h2> The declaration of ApplicationWindow
</h2>
<a name="1"></a><p> Here's the header file in full:
@@ -55,11 +55,11 @@ typical <tt>main()</tt> using <a href="qapplication.html">TQApplication</a>.
#ifndef APPLICATION_H
#define APPLICATION_H
-#include &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;
+#include &lt;<a href="qmainwindow-h.html">ntqmainwindow.h</a>&gt;
class TQTextEdit;
-class ApplicationWindow: public <a href="qmainwindow.html">TQMainWindow</a>
+class ApplicationWindow: public <a href="ntqmainwindow.html">TQMainWindow</a>
{
<a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
@@ -73,7 +73,7 @@ protected:
private slots:
void newDoc();
void choose();
- void load( const <a href="qstring.html">TQString</a> &amp;fileName );
+ void load( const <a href="ntqstring.html">TQString</a> &amp;fileName );
void save();
void saveAs();
void print();
@@ -82,20 +82,20 @@ private slots:
void aboutTQt();
private:
- <a href="qprinter.html">TQPrinter</a> *printer;
- <a href="qtextedit.html">TQTextEdit</a> *e;
- <a href="qstring.html">TQString</a> filename;
+ <a href="ntqprinter.html">TQPrinter</a> *printer;
+ <a href="ntqtextedit.html">TQTextEdit</a> *e;
+ <a href="ntqstring.html">TQString</a> filename;
};
#endif
</pre>
-<p> It declares a class that inherits <a href="qmainwindow.html">TQMainWindow</a>, with slots and private
-variables. The class pre-declaration of <a href="qtextedit.html">TQTextEdit</a> at the beginning
+<p> It declares a class that inherits <a href="ntqmainwindow.html">TQMainWindow</a>, with slots and private
+variables. The class pre-declaration of <a href="ntqtextedit.html">TQTextEdit</a> at the beginning
(instead of an include) helps to speed up compilation. With this
trick, <tt>make depend</tt> won't insist on recompiling every <tt>.cpp</tt> file that
-includes <tt>application.h</tt> when <a href="qtextedit-h.html">qtextedit.h</a> changes.
+includes <tt>application.h</tt> when <a href="qtextedit-h.html">ntqtextedit.h</a> changes.
<p> <a name="simplemain"></a>
<h2> A simple main()
</h2>
@@ -110,16 +110,16 @@ includes <tt>application.h</tt> when <a href="qtextedit-h.html">qtextedit.h</a>
**
*****************************************************************************/
-#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
+#include &lt;<a href="qapplication-h.html">ntqapplication.h</a>&gt;
#include "application.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 );
ApplicationWindow *mw = new ApplicationWindow();
- mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "TQt Example - Application" );
-<a name="x1598"></a> mw-&gt;<a href="qwidget.html#show">show</a>();
-<a name="x1599"></a> a.<a href="qobject.html#connect">connect</a>( &amp;a, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), &amp;a, SLOT(<a href="qapplication.html#quit">quit</a>()) );
- return a.<a href="qapplication.html#exec">exec</a>();
+ mw-&gt;<a href="ntqwidget.html#setCaption">setCaption</a>( "TQt Example - Application" );
+<a name="x1598"></a> mw-&gt;<a href="ntqwidget.html#show">show</a>();
+<a name="x1599"></a> a.<a href="ntqobject.html#connect">connect</a>( &amp;a, SIGNAL(<a href="ntqapplication.html#lastWindowClosed">lastWindowClosed</a>()), &amp;a, SLOT(<a href="ntqapplication.html#quit">quit</a>()) );
+ return a.<a href="ntqapplication.html#exec">exec</a>();
}
</pre>
@@ -127,25 +127,25 @@ int main( int argc, char ** argv ) {
<p>
<pre> int main( int argc, char ** argv ) {
- <a href="qapplication.html">TQApplication</a> a( argc, argv );
+ <a href="ntqapplication.html">TQApplication</a> a( argc, argv );
</pre>
-<p> With the above line, we create a <a href="qapplication.html">TQApplication</a> object with the usual
+<p> With the above line, we create a <a href="ntqapplication.html">TQApplication</a> object with the usual
constructor and let it
parse <em>argc</em> and <em>argv</em>. TQApplication itself takes care of X11-specific
command-line options like <em>-geometry</em>, so the program will automatically
behave the way X clients are expected to.
<p> <pre> ApplicationWindow *mw = new ApplicationWindow();
- mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "TQt Example - Application" );
- <a name="x2115"></a> mw-&gt;<a href="qwidget.html#show">show</a>();
+ mw-&gt;<a href="ntqwidget.html#setCaption">setCaption</a>( "TQt Example - Application" );
+ <a name="x2115"></a> mw-&gt;<a href="ntqwidget.html#show">show</a>();
</pre>
<p> We create an <em>ApplicationWindow</em> as a top-level widget, set its window
system caption to "Document 1", and <em>show()</em> it.
<p> <a name="close"></a>
-<pre> a.<a href="qobject.html#connect">connect</a>( &amp;a, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), &amp;a, SLOT(<a href="qapplication.html#quit">quit</a>()) );
+<pre> a.<a href="ntqobject.html#connect">connect</a>( &amp;a, SIGNAL(<a href="ntqapplication.html#lastWindowClosed">lastWindowClosed</a>()), &amp;a, SLOT(<a href="ntqapplication.html#quit">quit</a>()) );
</pre>
<p> When the application's last window is closed, it should quit. Both
-the signal and the slot are predefined members of <a href="qapplication.html">TQApplication</a>.
-<p> <pre> return a.<a href="qapplication.html#exec">exec</a>();
+the signal and the slot are predefined members of <a href="ntqapplication.html">TQApplication</a>.
+<p> <pre> return a.<a href="ntqapplication.html#exec">exec</a>();
</pre>
<p> Having completed the application's initialization, we start the main
event loop (the GUI), and eventually return the error code
@@ -171,32 +171,32 @@ moved a program to a different location and wondered why icons were
missing afterwards you will probably agree that it is a good idea to
compile them into the binary. This is what we are doing here.
<p> <pre> ApplicationWindow::ApplicationWindow()
- : <a href="qmainwindow.html">TQMainWindow</a>( 0, "example application main window", WDestructiveClose | WGroupLeader )
+ : <a href="ntqmainwindow.html">TQMainWindow</a>( 0, "example application main window", WDestructiveClose | WGroupLeader )
{
</pre>
-<p> <em>ApplicationWindow</em> inherits <a href="qmainwindow.html">TQMainWindow</a>, the TQt class that provides
+<p> <em>ApplicationWindow</em> inherits <a href="ntqmainwindow.html">TQMainWindow</a>, the TQt class that provides
typical application main windows, with menu bars, toolbars, etc.
-<p> <pre> printer = new <a href="qprinter.html">TQPrinter</a>( TQPrinter::HighResolution );
+<p> <pre> printer = new <a href="ntqprinter.html">TQPrinter</a>( TQPrinter::HighResolution );
</pre>
<p> The application example can print things, and we chose to have a
-<a href="qprinter.html">TQPrinter</a> object lying around so that when the user changes a setting
+<a href="ntqprinter.html">TQPrinter</a> object lying around so that when the user changes a setting
during one printing, the new setting will be the default next time.
-<p> <pre> <a href="qpixmap.html">TQPixmap</a> openIcon, saveIcon, printIcon;
+<p> <pre> <a href="ntqpixmap.html">TQPixmap</a> openIcon, saveIcon, printIcon;
</pre>
<p> For the sake of simplicity, our example only has a few commands in the
toolbar. The above variables are used to hold an icon for each of
them.
-<p> <pre> <a href="qtoolbar.html">TQToolBar</a> * fileTools = new <a href="qtoolbar.html">TQToolBar</a>( this, "file operations" );
+<p> <pre> <a href="ntqtoolbar.html">TQToolBar</a> * fileTools = new <a href="ntqtoolbar.html">TQToolBar</a>( this, "file operations" );
</pre>
<p> We create a toolbar in <em>this</em> window ...
-<p> <pre> fileTools-&gt;<a href="qtoolbar.html#setLabel">setLabel</a>( "File Operations" );
+<p> <pre> fileTools-&gt;<a href="ntqtoolbar.html#setLabel">setLabel</a>( "File Operations" );
</pre>
<p> ... and define a title for it. When a user drags the toolbar out of
its location and floats it over the desktop, the toolbar-window will
show "File Operations" as caption.
<p> <pre> openIcon = TQPixmap( fileopen );
TQToolButton * fileOpen
- = new <a href="qtoolbutton.html">TQToolButton</a>( openIcon, "Open File", <a href="qstring.html#TQString-null">TQString::null</a>,
+ = new <a href="ntqtoolbutton.html">TQToolButton</a>( openIcon, "Open File", <a href="ntqstring.html#TQString-null">TQString::null</a>,
this, SLOT(choose()), fileTools, "open file" );
</pre>
<p> Now we create the first tool button for the <em>fileTools</em> toolbar
@@ -206,12 +206,12 @@ contains the definition of a pixmap called <em>fileopen</em>.
We use this icon to illustrate our first tool button.
<p> <pre> saveIcon = TQPixmap( filesave );
TQToolButton * fileSave
- = new <a href="qtoolbutton.html">TQToolButton</a>( saveIcon, "Save File", TQString::null,
+ = new <a href="ntqtoolbutton.html">TQToolButton</a>( saveIcon, "Save File", TQString::null,
this, SLOT(save()), fileTools, "save file" );
printIcon = TQPixmap( fileprint );
TQToolButton * filePrint
- = new <a href="qtoolbutton.html">TQToolButton</a>( printIcon, "Print File", TQString::null,
+ = new <a href="ntqtoolbutton.html">TQToolButton</a>( printIcon, "Print File", TQString::null,
this, SLOT(print()), fileTools, "print file" );
</pre>
<p> In a similar way we create two more tool buttons in this toolbar, each with
@@ -228,7 +228,7 @@ function, as its mouse interface is unusual.
"You can also select the &lt;b&gt;Open&lt;/b&gt; command "
"from the &lt;b&gt;File&lt;/b&gt; menu.&lt;/p&gt;";
- TQWhatsThis::<a href="qwhatsthis.html#add">add</a>( fileOpen, fileOpenText );
+ TQWhatsThis::<a href="ntqwhatsthis.html#add">add</a>( fileOpen, fileOpenText );
</pre>
<p> With the above line we add the "What's This?" help-text to the
<em>fileOpen</em> button...
@@ -241,100 +241,100 @@ saved in <em>fileOpenText</em>) requests an image named "fileopen", the <em>open
"You can also select the &lt;b&gt;Save&lt;/b&gt; command "
"from the &lt;b&gt;File&lt;/b&gt; menu.&lt;/p&gt;";
- TQWhatsThis::<a href="qwhatsthis.html#add">add</a>( fileSave, fileSaveText );
+ TQWhatsThis::<a href="ntqwhatsthis.html#add">add</a>( fileSave, fileSaveText );
const char * filePrintText = "Click this button to print the file you "
"are editing.\n"
"You can also select the Print command "
"from the File menu.";
- TQWhatsThis::<a href="qwhatsthis.html#add">add</a>( filePrint, filePrintText );
+ TQWhatsThis::<a href="ntqwhatsthis.html#add">add</a>( filePrint, filePrintText );
</pre>
<p> The "What's This?" help of the remaining two buttons doesn't make use
of pixmaps, therefore all we need to do is to add the help-text to the
button. Be careful though: To invoke the rich-text elements in <tt>fileSaveText()</tt>, the entire string must be surrounded by &lt;p&gt; and
&lt;/p&gt;. In <tt>filePrintText()</tt>, we don't have rich-text elements, so
this is not necessary.
-<p> <pre> <a href="qpopupmenu.html">TQPopupMenu</a> * file = new <a href="qpopupmenu.html">TQPopupMenu</a>( this );
- <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
+<p> <pre> <a href="ntqpopupmenu.html">TQPopupMenu</a> * file = new <a href="ntqpopupmenu.html">TQPopupMenu</a>( this );
+ <a href="ntqmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
</pre>
-<p> Next we create a <a href="qpopupmenu.html">TQPopupMenu</a> for the <em>File</em> menu and
+<p> Next we create a <a href="ntqpopupmenu.html">TQPopupMenu</a> for the <em>File</em> menu and
add it to the menu bar. With the ampersand in front of the letter F,
we allow the user to use the shortcut <em>Alt+F</em> to pop up this menu.
-<p> <pre> file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;New", this, SLOT(newDoc()), CTRL+Key_N );
+<p> <pre> file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "&amp;New", this, SLOT(newDoc()), CTRL+Key_N );
</pre>
<p> Its first entry is connected to the (yet to be implemented) slot <tt>newDoc()</tt>. When the user chooses this <em>New</em> entry (e.g. by typing the
letter N as marked by the ampersand) or uses the
<em>Ctrl+N</em> accelerator, a new editor-window will pop up.
<p> <pre> int id;
- id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( openIcon, "&amp;Open...",
+ id = file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( openIcon, "&amp;Open...",
this, SLOT(choose()), CTRL+Key_O );
- file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileOpenText );
+ file-&gt;<a href="ntqmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileOpenText );
- id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( saveIcon, "&amp;Save",
+ id = file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( saveIcon, "&amp;Save",
this, SLOT(save()), CTRL+Key_S );
- file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
+ file-&gt;<a href="ntqmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
- id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Save &amp;As...", this, SLOT(saveAs()) );
- file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
+ id = file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "Save &amp;As...", this, SLOT(saveAs()) );
+ file-&gt;<a href="ntqmenudata.html#setWhatsThis">setWhatsThis</a>( id, fileSaveText );
</pre>
<p> We populate the <em>File</em> menu with three more commands (<em>Open</em>, <em>Save</em> and
<em>Save As</em>), and set "What's This?" help for them. Note in particular
that "What's This?" help and pixmaps are used in both the toolbar (above)
-and the menu bar (here). (See <a href="qaction.html">TQAction</a> and the <tt>examples/action</tt>
+and the menu bar (here). (See <a href="ntqaction.html">TQAction</a> and the <tt>examples/action</tt>
example for a shorter and easier approach.)
-<p> <pre> file-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
+<p> <pre> file-&gt;<a href="ntqmenudata.html#insertSeparator">insertSeparator</a>();
</pre>
<p> Then we insert a separator, ...
-<p> <pre> id = file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( printIcon, "&amp;Print...",
+<p> <pre> id = file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( printIcon, "&amp;Print...",
this, SLOT(print()), CTRL+Key_P );
- file-&gt;<a href="qmenudata.html#setWhatsThis">setWhatsThis</a>( id, filePrintText );
+ file-&gt;<a href="ntqmenudata.html#setWhatsThis">setWhatsThis</a>( id, filePrintText );
- file-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
+ file-&gt;<a href="ntqmenudata.html#insertSeparator">insertSeparator</a>();
- file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;Close", this, SLOT(<a href="qwidget.html#close">close</a>()), CTRL+Key_W );
- file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;Quit", qApp, SLOT( <a href="qapplication.html#closeAllWindows">closeAllWindows</a>() ), CTRL+Key_Q );
+ file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "&amp;Close", this, SLOT(<a href="ntqwidget.html#close">close</a>()), CTRL+Key_W );
+ file-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "&amp;Quit", qApp, SLOT( <a href="ntqapplication.html#closeAllWindows">closeAllWindows</a>() ), CTRL+Key_Q );
</pre>
<p> ... the <em>Print</em> command with "What's This?" help, another separator and
two more commands (<em>Close</em> and <em>Quit</em>) without "What's This?" and pixmaps.
In case of the <em>Close</em> command, the signal is connected
to the <em>close()</em> slot of the respective <em>ApplicationWindow</em> object whilst
the <em>Quit</em> command affects the entire application.
-<p> Because <em>ApplicationWindow</em> is a <a href="qwidget.html">TQWidget</a>, the <em>close()</em> function
+<p> Because <em>ApplicationWindow</em> is a <a href="ntqwidget.html">TQWidget</a>, the <em>close()</em> function
triggers a call to <a href="#closeEvent">closeEvent()</a> which we
will implement later.
<p> <a name="common_constructor"></a>
-<pre> <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertSeparator();
+<pre> <a href="ntqmainwindow.html#menuBar">menuBar</a>()-&gt;insertSeparator();
</pre>
<p> Now that we have done the File menu we shift our focus back to the
menu bar and insert a separator. From now on further menu bar entries
will be aligned to the right if the windows system style requires it.
-<p> <pre> <a href="qpopupmenu.html">TQPopupMenu</a> * help = new <a href="qpopupmenu.html">TQPopupMenu</a>( this );
- <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Help", help );
+<p> <pre> <a href="ntqpopupmenu.html">TQPopupMenu</a> * help = new <a href="ntqpopupmenu.html">TQPopupMenu</a>( this );
+ <a href="ntqmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Help", help );
- help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;About", this, SLOT(about()), Key_F1 );
- help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "About &amp;TQt", this, SLOT(aboutTQt()) );
- help-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
- help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "What's &amp;This", this, SLOT(<a href="qmainwindow.html#whatsThis">whatsThis</a>()), SHIFT+Key_F1 );
+ help-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "&amp;About", this, SLOT(about()), Key_F1 );
+ help-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "About &amp;TQt", this, SLOT(aboutTQt()) );
+ help-&gt;<a href="ntqmenudata.html#insertSeparator">insertSeparator</a>();
+ help-&gt;<a href="ntqmenudata.html#insertItem">insertItem</a>( "What's &amp;This", this, SLOT(<a href="ntqmainwindow.html#whatsThis">whatsThis</a>()), SHIFT+Key_F1 );
</pre>
<p> We create a <em>Help</em> menu, add it to the menu bar, and insert a few
commands. Depending on the style it will appear on the right hand
side of the menu bar or not.
-<p> <pre> e = new <a href="qtextedit.html">TQTextEdit</a>( this, "editor" );
- e-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
- <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( e );
+<p> <pre> e = new <a href="ntqtextedit.html">TQTextEdit</a>( this, "editor" );
+ e-&gt;<a href="ntqwidget.html#setFocus">setFocus</a>();
+ <a href="ntqmainwindow.html#setCentralWidget">setCentralWidget</a>( e );
</pre>
<p> Now we create a simple text-editor, set the initial focus to it,
and make it the window's central widget.
-<p> <a href="qmainwindow.html#centralWidget">TQMainWindow::centralWidget</a>() is the heart of the entire application:
+<p> <a href="ntqmainwindow.html#centralWidget">TQMainWindow::centralWidget</a>() is the heart of the entire application:
It's what menu bar, statusbar and toolbars are all arranged around. Since
the central widget is a text editing widget, we can now reveal that
our simple application is a text editor. :)
-<p> <pre> <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Ready", 2000 );
+<p> <pre> <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Ready", 2000 );
</pre>
<p> We make the statusbar say "Ready" for two seconds at startup, just to
tell the user that the window has finished initialization and can be
used.
-<p> <pre> <a href="qwidget.html#resize">resize</a>( 450, 600 );
+<p> <pre> <a href="ntqwidget.html#resize">resize</a>( 450, 600 );
</pre>
<p> Finally it's time to resize the new window to a a nice default size.
<p> <pre> }
@@ -355,8 +355,8 @@ and used in the constructor.
<pre> void ApplicationWindow::newDoc()
{
ApplicationWindow *ed = new ApplicationWindow;
- ed-&gt;<a href="qwidget.html#setCaption">setCaption</a>("TQt Example - Application");
- ed-&gt;<a href="qwidget.html#show">show</a>();
+ ed-&gt;<a href="ntqwidget.html#setCaption">setCaption</a>("TQt Example - Application");
+ ed-&gt;<a href="ntqwidget.html#show">show</a>();
}
</pre>
<p> This slot, connected to the <em>File|New</em> menu item, simply creates a
@@ -364,29 +364,29 @@ new <em>ApplicationWindow</em> and shows it.
<p> <a name="choose()"></a>
<pre> void ApplicationWindow::choose()
{
- <a href="qstring.html">TQString</a> fn = TQFileDialog::<a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>( TQString::null, TQString::null,
+ <a href="ntqstring.html">TQString</a> fn = TQFileDialog::<a href="ntqfiledialog.html#getOpenFileName">getOpenFileName</a>( TQString::null, TQString::null,
this);
- if ( !fn.<a href="qstring.html#isEmpty">isEmpty</a>() )
+ if ( !fn.<a href="ntqstring.html#isEmpty">isEmpty</a>() )
load( fn );
else
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Loading aborted", 2000 );
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Loading aborted", 2000 );
}
</pre>
<p> The <em>choose()</em> slot is connected to the <em>Open</em> menu item and
-tool button. With a little help from <a href="qfiledialog.html#getOpenFileName">TQFileDialog::getOpenFileName</a>(), it
+tool button. With a little help from <a href="ntqfiledialog.html#getOpenFileName">TQFileDialog::getOpenFileName</a>(), it
asks the user for a file name and then either loads that file or gives an
error message in the statusbar.
-<p> <pre> void ApplicationWindow::load( const <a href="qstring.html">TQString</a> &amp;fileName )
+<p> <pre> void ApplicationWindow::load( const <a href="ntqstring.html">TQString</a> &amp;fileName )
{
- <a href="qfile.html">TQFile</a> f( fileName );
- if ( !f.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) )
+ <a href="ntqfile.html">TQFile</a> f( fileName );
+ if ( !f.<a href="ntqfile.html#open">open</a>( <a href="ntqfile.html#open">IO_ReadOnly</a> ) )
return;
- <a href="qtextstream.html">TQTextStream</a> ts( &amp;f );
- e-&gt;<a href="qtextedit.html#setText">setText</a>( ts.<a href="qtextstream.html#read">read</a>() );
- e-&gt;<a href="qtextedit.html#setModified">setModified</a>( FALSE );
- <a href="qwidget.html#setCaption">setCaption</a>( fileName );
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Loaded document " + fileName, 2000 );
+ <a href="ntqtextstream.html">TQTextStream</a> ts( &amp;f );
+ e-&gt;<a href="ntqtextedit.html#setText">setText</a>( ts.<a href="ntqtextstream.html#read">read</a>() );
+ e-&gt;<a href="ntqtextedit.html#setModified">setModified</a>( FALSE );
+ <a href="ntqwidget.html#setCaption">setCaption</a>( fileName );
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Loaded document " + fileName, 2000 );
}
</pre>
<p> This function loads a file into the editor. When it's done, it sets the
@@ -401,33 +401,33 @@ readable, nothing happens.
return;
}
- <a href="qstring.html">TQString</a> text = e-&gt;<a href="qtextedit.html#text">text</a>();
- <a href="qfile.html">TQFile</a> f( filename );
- if ( !f.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> ) ) {
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( TQString("Could not write to %1").arg(filename),
+ <a href="ntqstring.html">TQString</a> text = e-&gt;<a href="ntqtextedit.html#text">text</a>();
+ <a href="ntqfile.html">TQFile</a> f( filename );
+ if ( !f.<a href="ntqfile.html#open">open</a>( <a href="ntqfile.html#open">IO_WriteOnly</a> ) ) {
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( TQString("Could not write to %1").arg(filename),
2000 );
return;
}
- <a href="qtextstream.html">TQTextStream</a> t( &amp;f );
+ <a href="ntqtextstream.html">TQTextStream</a> t( &amp;f );
t &lt;&lt; text;
- f.<a href="qfile.html#close">close</a>();
+ f.<a href="ntqfile.html#close">close</a>();
</pre>
<p> As its name suggests, this function saves the current file. If no
filename has been specified so far, the <a href="#saveAs()">saveAs()</a> function is called. Unwritable files cause the <em>ApplicationWindow</em> object to provide an error-message in the statusbar.
Note that there is more than one way to do this:
compare the above <tt>statusBar()-&gt;message()</tt> line with the equivalent
code in the <tt>load()</tt> function.
-<p> <pre> e-&gt;<a href="qtextedit.html#setModified">setModified</a>( FALSE );
+<p> <pre> e-&gt;<a href="ntqtextedit.html#setModified">setModified</a>( FALSE );
</pre>
<p> Tell the editor that the contents haven't been edited since the last
save. When the user does some further editing and wishes to close the
window without explicit saving, <a href="#closeEvent">ApplicationWindow::closeEvent()</a> will ask about it.
-<p> <pre> <a href="qwidget.html#setCaption">setCaption</a>( filename );
+<p> <pre> <a href="ntqwidget.html#setCaption">setCaption</a>( filename );
</pre>
<p> It may be that the document was saved under a different name than the
old caption suggests, so we set the window caption just to be sure.
-<p> <pre> <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( TQString( "File %1 saved" ).arg( filename ), 2000 );
+<p> <pre> <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( TQString( "File %1 saved" ).arg( filename ), 2000 );
}
</pre>
<p> With a message in the statusbar, we inform the user that the file
@@ -435,13 +435,13 @@ was saved successfully.
<p> <a name="saveAs()"></a>
<pre> void ApplicationWindow::saveAs()
{
- <a href="qstring.html">TQString</a> fn = TQFileDialog::<a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>( TQString::null, TQString::null,
+ <a href="ntqstring.html">TQString</a> fn = TQFileDialog::<a href="ntqfiledialog.html#getSaveFileName">getSaveFileName</a>( TQString::null, TQString::null,
this );
- if ( !fn.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
+ if ( !fn.<a href="ntqstring.html#isEmpty">isEmpty</a>() ) {
filename = fn;
save();
} else {
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Saving aborted", 2000 );
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Saving aborted", 2000 );
}
}
</pre>
@@ -450,42 +450,42 @@ and implicitly changes the window system caption to the new name.
<p> <a name="printer"></a>
<p> <pre> void ApplicationWindow::print()
{
- printer-&gt;<a href="qprinter.html#setFullPage">setFullPage</a>( TRUE );
- if ( printer-&gt;<a href="qprinter.html#setup">setup</a>(this) ) { // printer dialog
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing..." );
- <a href="qpainter.html">TQPainter</a> p;
- if( !p.<a href="qpainter.html#begin">begin</a>( printer ) ) { // paint on printer
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing aborted", 2000 );
+ printer-&gt;<a href="ntqprinter.html#setFullPage">setFullPage</a>( TRUE );
+ if ( printer-&gt;<a href="ntqprinter.html#setup">setup</a>(this) ) { // printer dialog
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing..." );
+ <a href="ntqpainter.html">TQPainter</a> p;
+ if( !p.<a href="ntqpainter.html#begin">begin</a>( printer ) ) { // paint on printer
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing aborted", 2000 );
return;
}
- <a href="qpaintdevicemetrics.html">TQPaintDeviceMetrics</a> metrics( p.<a href="qpainter.html#device">device</a>() );
- int dpiy = metrics.<a href="qpaintdevicemetrics.html#logicalDpiY">logicalDpiY</a>();
+ <a href="ntqpaintdevicemetrics.html">TQPaintDeviceMetrics</a> metrics( p.<a href="ntqpainter.html#device">device</a>() );
+ int dpiy = metrics.<a href="ntqpaintdevicemetrics.html#logicalDpiY">logicalDpiY</a>();
int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
- <a href="qrect.html">TQRect</a> view( margin, margin, metrics.<a href="qpaintdevicemetrics.html#width">width</a>() - 2*margin, metrics.<a href="qpaintdevicemetrics.html#height">height</a>() - 2*margin );
- <a href="qsimplerichtext.html">TQSimpleRichText</a> richText( TQStyleSheet::<a href="qstylesheet.html#convertFromPlainText">convertFromPlainText</a>(e-&gt;<a href="qtextedit.html#text">text</a>()),
+ <a href="ntqrect.html">TQRect</a> view( margin, margin, metrics.<a href="ntqpaintdevicemetrics.html#width">width</a>() - 2*margin, metrics.<a href="ntqpaintdevicemetrics.html#height">height</a>() - 2*margin );
+ <a href="ntqsimplerichtext.html">TQSimpleRichText</a> richText( TQStyleSheet::<a href="ntqstylesheet.html#convertFromPlainText">convertFromPlainText</a>(e-&gt;<a href="ntqtextedit.html#text">text</a>()),
TQFont(),
- e-&gt;<a href="qtextedit.html#context">context</a>(),
- e-&gt;<a href="qtextedit.html#styleSheet">styleSheet</a>(),
- e-&gt;<a href="qtextedit.html#mimeSourceFactory">mimeSourceFactory</a>(),
- view.<a href="qrect.html#height">height</a>() );
- richText.<a href="qsimplerichtext.html#setWidth">setWidth</a>( &amp;p, view.<a href="qrect.html#width">width</a>() );
+ e-&gt;<a href="ntqtextedit.html#context">context</a>(),
+ e-&gt;<a href="ntqtextedit.html#styleSheet">styleSheet</a>(),
+ e-&gt;<a href="ntqtextedit.html#mimeSourceFactory">mimeSourceFactory</a>(),
+ view.<a href="ntqrect.html#height">height</a>() );
+ richText.<a href="ntqsimplerichtext.html#setWidth">setWidth</a>( &amp;p, view.<a href="ntqrect.html#width">width</a>() );
int page = 1;
do {
- richText.<a href="qsimplerichtext.html#draw">draw</a>( &amp;p, margin, margin, view, colorGroup() );
- view.<a href="qrect.html#moveBy">moveBy</a>( 0, view.<a href="qrect.html#height">height</a>() );
- p.<a href="qpainter.html#translate">translate</a>( 0 , -view.<a href="qrect.html#height">height</a>() );
- p.<a href="qpainter.html#drawText">drawText</a>( view.<a href="qrect.html#right">right</a>() - p.<a href="qpainter.html#fontMetrics">fontMetrics</a>().width( TQString::<a href="qstring.html#number">number</a>( page ) ),
- view.<a href="qrect.html#bottom">bottom</a>() + p.<a href="qpainter.html#fontMetrics">fontMetrics</a>().ascent() + 5, TQString::number( page ) );
- if ( view.<a href="qrect.html#top">top</a>() - margin &gt;= richText.<a href="qsimplerichtext.html#height">height</a>() )
+ richText.<a href="ntqsimplerichtext.html#draw">draw</a>( &amp;p, margin, margin, view, colorGroup() );
+ view.<a href="ntqrect.html#moveBy">moveBy</a>( 0, view.<a href="ntqrect.html#height">height</a>() );
+ p.<a href="ntqpainter.html#translate">translate</a>( 0 , -view.<a href="ntqrect.html#height">height</a>() );
+ p.<a href="ntqpainter.html#drawText">drawText</a>( view.<a href="ntqrect.html#right">right</a>() - p.<a href="ntqpainter.html#fontMetrics">fontMetrics</a>().width( TQString::<a href="ntqstring.html#number">number</a>( page ) ),
+ view.<a href="ntqrect.html#bottom">bottom</a>() + p.<a href="ntqpainter.html#fontMetrics">fontMetrics</a>().ascent() + 5, TQString::number( page ) );
+ if ( view.<a href="ntqrect.html#top">top</a>() - margin &gt;= richText.<a href="ntqsimplerichtext.html#height">height</a>() )
break;
- printer-&gt;<a href="qprinter.html#newPage">newPage</a>();
+ printer-&gt;<a href="ntqprinter.html#newPage">newPage</a>();
page++;
} while (TRUE);
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing completed", 2000 );
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing completed", 2000 );
} else {
- <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing aborted", 2000 );
+ <a href="ntqmainwindow.html#statusBar">statusBar</a>()-&gt;message( "Printing aborted", 2000 );
}
}
</pre>
@@ -493,28 +493,28 @@ and implicitly changes the window system caption to the new name.
tool button.
<p> We present the user with the print setup dialog, and abandon printing
if they cancel.
-<p> We create a <a href="qsimplerichtext.html">TQSimpleRichText</a> object and give it the text. This object
+<p> We create a <a href="ntqsimplerichtext.html">TQSimpleRichText</a> object and give it the text. This object
is able to format the text nicely as one long page. We achieve
pagination by printing one paper page's worth of text from the
TQSimpleRichText page at a time.
<p> Now let's see what happens when a user wishes to <em>close()</em>
an <em>ApplicationWindow</em>.
<p> <a name="closeEvent"></a>
-<pre> void ApplicationWindow::<a href="qwidget.html#closeEvent">closeEvent</a>( <a href="qcloseevent.html">TQCloseEvent</a>* ce )
+<pre> void ApplicationWindow::<a href="ntqwidget.html#closeEvent">closeEvent</a>( <a href="qcloseevent.html">TQCloseEvent</a>* ce )
{
</pre>
<p> This event gets to process window system close events. A close event is
subtly different from a hide event: hide often means "iconify" whereas
close means that the window is going away for good.
-<p> <pre> if ( !e-&gt;<a href="qtextedit.html#isModified">isModified</a>() ) {
+<p> <pre> if ( !e-&gt;<a href="ntqtextedit.html#isModified">isModified</a>() ) {
ce-&gt;<a href="qcloseevent.html#accept">accept</a>();
return;
}
</pre>
<p> If the text hasn't been edited, we just accept the event. The window
-will be closed, and because we used the <em>WDestructiveClose</em> <a href="qt.html#WidgetFlags">widget flag</a> in the <a href="#ApplicationWindow"><i>ApplicationWindow()</i> constructor</a>,
+will be closed, and because we used the <em>WDestructiveClose</em> <a href="ntqt.html#WidgetFlags">widget flag</a> in the <a href="#ApplicationWindow"><i>ApplicationWindow()</i> constructor</a>,
the widget will be deleted.
-<p> <pre> switch( TQMessageBox::<a href="qmessagebox.html#information">information</a>( this, "TQt Application Example",
+<p> <pre> switch( TQMessageBox::<a href="ntqmessagebox.html#information">information</a>( this, "TQt Application Example",
"Do you want to save the changes"
" to the document?",
"Yes", "No", "Cancel",
@@ -546,14 +546,14 @@ simple.
<p> Last but not least we implement the slots used by the help menu entries.
<p> <pre> void ApplicationWindow::about()
{
- TQMessageBox::<a href="qmessagebox.html#about">about</a>( this, "TQt Application Example",
+ TQMessageBox::<a href="ntqmessagebox.html#about">about</a>( this, "TQt Application Example",
"This example demonstrates simple use of "
"TQMainWindow,\nTQMenuBar and TQToolBar.");
}
void ApplicationWindow::aboutTQt()
{
- TQMessageBox::<a href="qmessagebox.html#aboutTQt">aboutTQt</a>( this, "TQt Application Example" );
+ TQMessageBox::<a href="ntqmessagebox.html#aboutTQt">aboutTQt</a>( this, "TQt Application Example" );
}
</pre>
<p> These two slots use ready-made "about" functions to provide some