diff options
Diffstat (limited to 'doc/html/tutorial2-05.html')
-rw-r--r-- | doc/html/tutorial2-05.html | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/doc/html/tutorial2-05.html b/doc/html/tutorial2-05.html index afd4014e8..edeee15f0 100644 --- a/doc/html/tutorial2-05.html +++ b/doc/html/tutorial2-05.html @@ -40,7 +40,7 @@ conventional document-centric style. <p> (Extracts from <tt>chartform.h</tt>.) <p> -<pre> class ChartForm: public <a href="ntqmainwindow.html">TQMainWindow</a> +<pre> class ChartForm: public <a href="tqmainwindow.html">TQMainWindow</a> { <a href="metaobjects.html#TQ_OBJECT">TQ_OBJECT</a> public: @@ -56,7 +56,7 @@ conventional document-centric style. void setChanged( bool changed = TRUE ) { m_changed = changed; } void drawElements(); - <a href="ntqpopupmenu.html">TQPopupMenu</a> *optionsMenu; // Why public? See canvasview.cpp + <a href="tqpopupmenu.html">TQPopupMenu</a> *optionsMenu; // Why public? See canvasview.cpp protected: virtual void closeEvent( <a href="qcloseevent.html">TQCloseEvent</a> * ); @@ -71,7 +71,7 @@ conventional document-centric style. void filePrint(); void fileQuit(); void optionsSetData(); - void updateChartType( <a href="ntqaction.html">TQAction</a> *action ); + void updateChartType( <a href="tqaction.html">TQAction</a> *action ); void optionsSetFont(); void optionsSetOptions(); void helpHelp(); @@ -92,10 +92,10 @@ conventional document-centric style. void updateRecentFilesMenu(); void setChartType( ChartType chartType ); - <a href="ntqpopupmenu.html">TQPopupMenu</a> *fileMenu; - <a href="ntqaction.html">TQAction</a> *optionsPieChartAction; - <a href="ntqaction.html">TQAction</a> *optionsHorizontalBarChartAction; - <a href="ntqaction.html">TQAction</a> *optionsVerticalBarChartAction; + <a href="tqpopupmenu.html">TQPopupMenu</a> *fileMenu; + <a href="tqaction.html">TQAction</a> *optionsPieChartAction; + <a href="tqaction.html">TQAction</a> *optionsHorizontalBarChartAction; + <a href="tqaction.html">TQAction</a> *optionsVerticalBarChartAction; <a href="tqstring.html">TQString</a> m_filename; <a href="tqstringlist.html">TQStringList</a> m_recentFiles; <a href="tqcanvas.html">TQCanvas</a> *m_canvas; @@ -109,7 +109,7 @@ conventional document-centric style. <a href="ntqfont.html">TQFont</a> m_font; }; </pre> -<p> We create a <tt>ChartForm</tt> subclass of <a href="ntqmainwindow.html">TQMainWindow</a>. Our subclass uses +<p> We create a <tt>ChartForm</tt> subclass of <a href="tqmainwindow.html">TQMainWindow</a>. Our subclass uses the <a href="metaobjects.html#TQ_OBJECT">TQ_OBJECT</a> macro to support TQt's <a href="signalsandslots.html">signals and slots</a> mechanism. <p> The public interface is very small; the type of chart being displayed can be retrieved, the chart can be marked 'changed' (so that the user @@ -144,13 +144,13 @@ which we've placed in the <tt>images</tt> subdirectory. <p> <h2> The Constructor </h2> <a name="2"></a><p> <pre> ChartForm::ChartForm( const <a href="tqstring.html">TQString</a>& filename ) - : <a href="ntqmainwindow.html">TQMainWindow</a>( 0, 0, WDestructiveClose ) + : <a href="tqmainwindow.html">TQMainWindow</a>( 0, 0, WDestructiveClose ) </pre><tt>...</tt> -<pre> <a href="ntqaction.html">TQAction</a> *fileNewAction; - <a href="ntqaction.html">TQAction</a> *fileOpenAction; - <a href="ntqaction.html">TQAction</a> *fileSaveAction; +<pre> <a href="tqaction.html">TQAction</a> *fileNewAction; + <a href="tqaction.html">TQAction</a> *fileOpenAction; + <a href="tqaction.html">TQAction</a> *fileSaveAction; </pre> -<p> For each user action we declare a <a href="ntqaction.html">TQAction</a> pointer. Some actions are +<p> For each user action we declare a <a href="tqaction.html">TQAction</a> pointer. Some actions are declared in the header file because they need to be referred to outside of the constructor. <p> <center><table cellpadding="4" cellspacing="2" border="0"> @@ -160,10 +160,10 @@ buttons. TQt allows us to create a single TQAction which can be added to both a menu and a toolbar. This approach ensures that menu items and toolbar buttons stay in sync and saves duplicating code. </table></center> -<p> <pre> fileNewAction = new <a href="ntqaction.html">TQAction</a>( +<p> <pre> fileNewAction = new <a href="tqaction.html">TQAction</a>( "New Chart", TQPixmap( file_new ), "&New", CTRL+Key_N, this, "new" ); - <a href="tqobject.html#connect">connect</a>( fileNewAction, TQ_SIGNAL( <a href="ntqaction.html#activated">activated</a>() ), this, TQ_SLOT( fileNew() ) ); + <a href="tqobject.html#connect">connect</a>( fileNewAction, TQ_SIGNAL( <a href="tqaction.html#activated">activated</a>() ), this, TQ_SLOT( fileNew() ) ); </pre> <p> When we construct an action we give it a name, an optional icon, a menu text, and an accelerator short-cut key (or 0 if no accelerator is @@ -175,17 +175,17 @@ action's slot, in the snippet shown above, to fileNew(). that if the user selects the pie chart menu option, the pie chart toolbar button must be automatically selected too, and the other chart menu options and toolbar buttons must be automatically unselected. -This behaviour is achieved by creating a <a href="qactiongroup.html">TQActionGroup</a> and placing the +This behaviour is achieved by creating a <a href="tqactiongroup.html">TQActionGroup</a> and placing the chart type actions in the group. -<p> <pre> <a href="qactiongroup.html">TQActionGroup</a> *chartGroup = new <a href="qactiongroup.html">TQActionGroup</a>( this ); // Connected later - chartGroup-><a href="qactiongroup.html#setExclusive">setExclusive</a>( TRUE ); +<p> <pre> <a href="tqactiongroup.html">TQActionGroup</a> *chartGroup = new <a href="tqactiongroup.html">TQActionGroup</a>( this ); // Connected later + chartGroup-><a href="tqactiongroup.html#setExclusive">setExclusive</a>( TRUE ); </pre> <p> The action group becomes a child of the form (<tt>this</tt>) and the exlusive behaviour is achieved by the setExclusive() call. -<p> <pre> optionsPieChartAction = new <a href="ntqaction.html">TQAction</a>( +<p> <pre> optionsPieChartAction = new <a href="tqaction.html">TQAction</a>( "Pie Chart", TQPixmap( options_piechart ), "&Pie Chart", CTRL+Key_I, chartGroup, "pie chart" ); - optionsPieChartAction-><a href="ntqaction.html#setToggleAction">setToggleAction</a>( TRUE ); + optionsPieChartAction-><a href="tqaction.html#setToggleAction">setToggleAction</a>( TRUE ); </pre> <p> Each action in the group is created in the same way as other actions, except that the action's parent is the group rather than the form. @@ -205,17 +205,17 @@ canvas type we will connect the group. </table></center> <p> Once we've created all our user actions we can create the toolbars and menu options that will allow the user to invoke them. -<p> <pre> <a href="ntqtoolbar.html">TQToolBar</a>* fileTools = new <a href="ntqtoolbar.html">TQToolBar</a>( this, "file operations" ); - fileTools-><a href="ntqtoolbar.html#setLabel">setLabel</a>( "File Operations" ); - fileNewAction-><a href="ntqaction.html#addTo">addTo</a>( fileTools ); - fileOpenAction-><a href="ntqaction.html#addTo">addTo</a>( fileTools ); - fileSaveAction-><a href="ntqaction.html#addTo">addTo</a>( fileTools ); +<p> <pre> <a href="tqtoolbar.html">TQToolBar</a>* fileTools = new <a href="tqtoolbar.html">TQToolBar</a>( this, "file operations" ); + fileTools-><a href="tqtoolbar.html#setLabel">setLabel</a>( "File Operations" ); + fileNewAction-><a href="tqaction.html#addTo">addTo</a>( fileTools ); + fileOpenAction-><a href="tqaction.html#addTo">addTo</a>( fileTools ); + fileSaveAction-><a href="tqaction.html#addTo">addTo</a>( fileTools ); </pre><tt>...</tt> -<pre> fileMenu = new <a href="ntqpopupmenu.html">TQPopupMenu</a>( this ); - <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertItem( "&File", fileMenu ); - fileNewAction-><a href="ntqaction.html#addTo">addTo</a>( fileMenu ); - fileOpenAction-><a href="ntqaction.html#addTo">addTo</a>( fileMenu ); - fileSaveAction-><a href="ntqaction.html#addTo">addTo</a>( fileMenu ); +<pre> fileMenu = new <a href="tqpopupmenu.html">TQPopupMenu</a>( this ); + <a href="tqmainwindow.html#menuBar">menuBar</a>()->insertItem( "&File", fileMenu ); + fileNewAction-><a href="tqaction.html#addTo">addTo</a>( fileMenu ); + fileOpenAction-><a href="tqaction.html#addTo">addTo</a>( fileMenu ); + fileSaveAction-><a href="tqaction.html#addTo">addTo</a>( fileMenu ); </pre> <p> Toolbar actions and menu options are easily created from TQActions. <p> As a convenience to our users we will restore the last window position @@ -257,7 +257,7 @@ the settings. We attempt to read each possible file entry ("File1" to "File9"), and add each non-empty entry to the list of recently used files. If there are one or more recently used files we update the File menu by calling updateRecentFilesMenu(); (we'll review this later on). -<p> <pre> <a href="tqobject.html#connect">connect</a>( chartGroup, TQ_SIGNAL( <a href="qactiongroup.html#selected">selected</a>(TQAction*) ), +<p> <pre> <a href="tqobject.html#connect">connect</a>( chartGroup, TQ_SIGNAL( <a href="tqactiongroup.html#selected">selected</a>(TQAction*) ), this, TQ_SLOT( updateChartType(TQAction*) ) ); </pre> <p> Now that we have set the chart type (when we read it in as a user @@ -272,7 +272,7 @@ move the chart form's window accordingly. <p> <pre> m_canvas = new <a href="tqcanvas.html">TQCanvas</a>( this ); m_canvas-><a href="tqcanvas.html#resize">resize</a>( <a href="tqwidget.html#width">width</a>(), height() ); m_canvasView = new CanvasView( m_canvas, &m_elements, this ); - <a href="ntqmainwindow.html#setCentralWidget">setCentralWidget</a>( m_canvasView ); + <a href="tqmainwindow.html#setCentralWidget">setCentralWidget</a>( m_canvasView ); m_canvasView-><a href="tqwidget.html#show">show</a>(); </pre> <p> We create a new <a href="tqcanvas.html">TQCanvas</a> and set its size to that of the chart form @@ -293,7 +293,7 @@ chart form's main widget and show it. </pre> <p> If we have a file to load we load it; otherwise we initialise our elements vector and draw a sample chart. -<p> <pre> <a href="ntqmainwindow.html#statusBar">statusBar</a>()->message( "Ready", 2000 ); +<p> <pre> <a href="tqmainwindow.html#statusBar">statusBar</a>()->message( "Ready", 2000 ); </pre> <p> It is <em>vital</em> that we call statusBar() in the constructor, since the call ensures that a status bar is created for this main window. @@ -389,7 +389,7 @@ added a call to optionsSetData() and see which you prefer. <a name="x2567"></a> if ( !filename.<a href="tqstring.html#isEmpty">isEmpty</a>() ) load( filename ); else - <a href="ntqmainwindow.html#statusBar">statusBar</a>()->message( "File Open abandoned", 2000 ); + <a href="tqmainwindow.html#statusBar">statusBar</a>()->message( "File Open abandoned", 2000 ); } </pre> <p> We check that it is okToClear(). If it is we use the static @@ -417,7 +417,7 @@ the user wishes to load. If we get a filename we call load(). return; } } - <a href="ntqmainwindow.html#statusBar">statusBar</a>()->message( "Saving abandoned", 2000 ); + <a href="tqmainwindow.html#statusBar">statusBar</a>()->message( "Saving abandoned", 2000 ); } </pre> <p> This function calls the static <a href="ntqfiledialog.html#getSaveFileName">TQFileDialog::getSaveFileName</a>() to get @@ -437,10 +437,10 @@ opened files list and call fileSave() (covered in <a href="tutorial2-07.html">Fi <pre> void ChartForm::updateRecentFilesMenu() { for ( int i = 0; i < MAX_RECENTFILES; ++i ) { - if ( fileMenu-><a href="ntqmenudata.html#findItem">findItem</a>( i ) ) - fileMenu-><a href="ntqmenudata.html#removeItem">removeItem</a>( i ); + if ( fileMenu-><a href="tqmenudata.html#findItem">findItem</a>( i ) ) + fileMenu-><a href="tqmenudata.html#removeItem">removeItem</a>( i ); if ( i < int(m_recentFiles.count()) ) - fileMenu-><a href="ntqmenudata.html#insertItem">insertItem</a>( TQString( "&%1 %2" ). + fileMenu-><a href="tqmenudata.html#insertItem">insertItem</a>( TQString( "&%1 %2" ). arg( i + 1 ).arg( m_recentFiles[i] ), this, TQ_SLOT( fileOpenRecent(int) ), 0, i ); |