diff options
Diffstat (limited to 'doc/html/tutorial2-08.html')
-rw-r--r-- | doc/html/tutorial2-08.html | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/doc/html/tutorial2-08.html b/doc/html/tutorial2-08.html index 6bd21ee6b..210da5231 100644 --- a/doc/html/tutorial2-08.html +++ b/doc/html/tutorial2-08.html @@ -59,7 +59,7 @@ enter label text and choose a label color for each label. void accept(); private: - <a href="ntqtable.html">TQTable</a> *table; + <a href="tqtable.html">TQTable</a> *table; <a href="tqpushbutton.html">TQPushButton</a> *colorPushButton; <a href="tqpushbutton.html">TQPushButton</a> *okPushButton; <a href="tqpushbutton.html">TQPushButton</a> *cancelPushButton; @@ -109,26 +109,26 @@ member functions. <p> The layout of the form is quite simple. The buttons will be grouped together in a horizontal layout and the table and the button layout will be grouped together vertically using the tableButtonBox layout. -<p> <pre> table = new <a href="ntqtable.html">TQTable</a>( this, "data table" ); - <a name="x2621"></a> table-><a href="ntqtable.html#setNumCols">setNumCols</a>( 5 ); - <a name="x2622"></a> table-><a href="ntqtable.html#setNumRows">setNumRows</a>( ChartForm::MAX_ELEMENTS ); - <a name="x2619"></a> table-><a href="ntqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 1, TRUE ); - table-><a href="ntqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 2, TRUE ); - table-><a href="ntqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 4, TRUE ); - <a name="x2620"></a> table-><a href="ntqtable.html#setColumnWidth">setColumnWidth</a>( 0, 80 ); - table-><a href="ntqtable.html#setColumnWidth">setColumnWidth</a>( 1, 60 ); // Columns 1 and 4 must be equal - table-><a href="ntqtable.html#setColumnWidth">setColumnWidth</a>( 2, 60 ); - table-><a href="ntqtable.html#setColumnWidth">setColumnWidth</a>( 3, 200 ); - table-><a href="ntqtable.html#setColumnWidth">setColumnWidth</a>( 4, 60 ); - <a name="x2616"></a> <a href="ntqheader.html">TQHeader</a> *th = table-><a href="ntqtable.html#horizontalHeader">horizontalHeader</a>(); - <a name="x2605"></a> th-><a href="ntqheader.html#setLabel">setLabel</a>( 0, "Value" ); - th-><a href="ntqheader.html#setLabel">setLabel</a>( 1, "Color" ); - th-><a href="ntqheader.html#setLabel">setLabel</a>( 2, "Pattern" ); - th-><a href="ntqheader.html#setLabel">setLabel</a>( 3, "Label" ); - th-><a href="ntqheader.html#setLabel">setLabel</a>( 4, "Color" ); +<p> <pre> table = new <a href="tqtable.html">TQTable</a>( this, "data table" ); + <a name="x2621"></a> table-><a href="tqtable.html#setNumCols">setNumCols</a>( 5 ); + <a name="x2622"></a> table-><a href="tqtable.html#setNumRows">setNumRows</a>( ChartForm::MAX_ELEMENTS ); + <a name="x2619"></a> table-><a href="tqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 1, TRUE ); + table-><a href="tqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 2, TRUE ); + table-><a href="tqtable.html#setColumnReadOnly">setColumnReadOnly</a>( 4, TRUE ); + <a name="x2620"></a> table-><a href="tqtable.html#setColumnWidth">setColumnWidth</a>( 0, 80 ); + table-><a href="tqtable.html#setColumnWidth">setColumnWidth</a>( 1, 60 ); // Columns 1 and 4 must be equal + table-><a href="tqtable.html#setColumnWidth">setColumnWidth</a>( 2, 60 ); + table-><a href="tqtable.html#setColumnWidth">setColumnWidth</a>( 3, 200 ); + table-><a href="tqtable.html#setColumnWidth">setColumnWidth</a>( 4, 60 ); + <a name="x2616"></a> <a href="tqheader.html">TQHeader</a> *th = table-><a href="tqtable.html#horizontalHeader">horizontalHeader</a>(); + <a name="x2605"></a> th-><a href="tqheader.html#setLabel">setLabel</a>( 0, "Value" ); + th-><a href="tqheader.html#setLabel">setLabel</a>( 1, "Color" ); + th-><a href="tqheader.html#setLabel">setLabel</a>( 2, "Pattern" ); + th-><a href="tqheader.html#setLabel">setLabel</a>( 3, "Label" ); + th-><a href="tqheader.html#setLabel">setLabel</a>( 4, "Color" ); tableButtonBox-><a href="qboxlayout.html#addWidget">addWidget</a>( table ); </pre> -<p> We create a new <a href="ntqtable.html">TQTable</a> with five columns, and the same number of rows +<p> We create a new <a href="tqtable.html">TQTable</a> with five columns, and the same number of rows as we have elements in the elements vector. We make the color and pattern columns read only: this is to prevent the user typing in them. We will make the color changeable by the user clicking on a color or @@ -140,7 +140,7 @@ column and finally add the table to the tableButtonBox layout. </pre> <p> We create a horizontal box layout to hold the buttons. <p> <pre> colorPushButton = new <a href="tqpushbutton.html">TQPushButton</a>( this, "color button" ); - <a name="x2598"></a> colorPushButton-><a href="ntqbutton.html#setText">setText</a>( "&Color..." ); + <a name="x2598"></a> colorPushButton-><a href="tqbutton.html#setText">setText</a>( "&Color..." ); colorPushButton-><a href="tqwidget.html#setEnabled">setEnabled</a>( FALSE ); buttonBox-><a href="qboxlayout.html#addWidget">addWidget</a>( colorPushButton ); </pre> @@ -154,13 +154,13 @@ on a color cell. <p> Since we want to separate the color button from the OK and Cancel buttons we next create a spacer and add that to the buttonBox layout. <p> <pre> okPushButton = new <a href="tqpushbutton.html">TQPushButton</a>( this, "ok button" ); - okPushButton-><a href="ntqbutton.html#setText">setText</a>( "OK" ); + okPushButton-><a href="tqbutton.html#setText">setText</a>( "OK" ); <a name="x2607"></a> okPushButton-><a href="tqpushbutton.html#setDefault">setDefault</a>( TRUE ); buttonBox-><a href="qboxlayout.html#addWidget">addWidget</a>( okPushButton ); cancelPushButton = new <a href="tqpushbutton.html">TQPushButton</a>( this, "cancel button" ); - cancelPushButton-><a href="ntqbutton.html#setText">setText</a>( "Cancel" ); - <a name="x2597"></a> cancelPushButton-><a href="ntqbutton.html#setAccel">setAccel</a>( Key_Escape ); + cancelPushButton-><a href="tqbutton.html#setText">setText</a>( "Cancel" ); + <a name="x2597"></a> cancelPushButton-><a href="tqbutton.html#setAccel">setAccel</a>( Key_Escape ); buttonBox-><a href="qboxlayout.html#addWidget">addWidget</a>( cancelPushButton ); </pre> <p> The OK and Cancel buttons are created and added to the buttonBox. We @@ -170,22 +170,22 @@ key an accelerator for the Cancel button. </pre> <p> We add the buttonBox layout to the tableButtonBox and the layout is complete. -<p> <pre> <a name="x2612"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="ntqtable.html#clicked">clicked</a>(int,int,int,const <a href="tqpoint.html">TQPoint</a>&) ), +<p> <pre> <a name="x2612"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="tqtable.html#clicked">clicked</a>(int,int,int,const <a href="tqpoint.html">TQPoint</a>&) ), this, TQ_SLOT( setColor(int,int) ) ); - <a name="x2613"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="ntqtable.html#currentChanged">currentChanged</a>(int,int) ), + <a name="x2613"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="tqtable.html#currentChanged">currentChanged</a>(int,int) ), this, TQ_SLOT( currentChanged(int,int) ) ); - <a name="x2626"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="ntqtable.html#valueChanged">valueChanged</a>(int,int) ), + <a name="x2626"></a> <a href="tqobject.html#connect">connect</a>( table, TQ_SIGNAL( <a href="tqtable.html#valueChanged">valueChanged</a>(int,int) ), this, TQ_SLOT( valueChanged(int,int) ) ); - <a name="x2596"></a> <a href="tqobject.html#connect">connect</a>( colorPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( setColor() ) ); - <a href="tqobject.html#connect">connect</a>( okPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="tqdialog.html#accept">accept</a>() ) ); - <a href="tqobject.html#connect">connect</a>( cancelPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="tqdialog.html#reject">reject</a>() ) ); + <a name="x2596"></a> <a href="tqobject.html#connect">connect</a>( colorPushButton, TQ_SIGNAL( <a href="tqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( setColor() ) ); + <a href="tqobject.html#connect">connect</a>( okPushButton, TQ_SIGNAL( <a href="tqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="tqdialog.html#accept">accept</a>() ) ); + <a href="tqobject.html#connect">connect</a>( cancelPushButton, TQ_SIGNAL( <a href="tqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="tqdialog.html#reject">reject</a>() ) ); </pre> <p> We now "wire up" the form. <ul> <li> If the user clicks a cell we call the setColor() slot; this will check that the cell is one that holds a color, and if it is, will invoke the color dialog. -<li> We connect the <a href="ntqtable.html">TQTable</a>'s currentChanged() signal to our own +<li> We connect the <a href="tqtable.html">TQTable</a>'s currentChanged() signal to our own currentChanged() slot; this will be used to enable/disable the color button for example, depending on which column the user is in. <li> We connect the table's valueChanged() signal to our own @@ -202,7 +202,7 @@ requires no further code or action on our part. patterns[1] = TQPixmap( pattern02 ); </pre> <p> We create a pixmap for every brush pattern and store them in the <tt>patterns</tt> array. -<p> <pre> <a name="x2610"></a> <a href="tqrect.html">TQRect</a> rect = table-><a href="ntqtable.html#cellRect">cellRect</a>( 0, 1 ); +<p> <pre> <a name="x2610"></a> <a href="tqrect.html">TQRect</a> rect = table-><a href="tqtable.html#cellRect">cellRect</a>( 0, 1 ); <a href="tqpixmap.html">TQPixmap</a> pix( rect.<a href="tqrect.html#width">width</a>(), rect.<a href="tqrect.html#height">height</a>() ); </pre> <p> We obtain the rectangle that will be occupied by each color cell and @@ -211,28 +211,28 @@ create a blank pixmap of that size. Element element = (*m_elements)[i]; if ( element.isValid() ) - table-><a href="ntqtable.html#setText">setText</a>( + table-><a href="tqtable.html#setText">setText</a>( i, 0, TQString( "%1" ).arg( element.value(), 0, 'f', m_decimalPlaces ) ); <a href="tqcolor.html">TQColor</a> color = element.valueColor(); pix.<a href="tqpixmap.html#fill">fill</a>( color ); - table-><a href="ntqtable.html#setPixmap">setPixmap</a>( i, 1, pix ); - table-><a href="ntqtable.html#setText">setText</a>( i, 1, color.<a href="tqcolor.html#name">name</a>() ); + table-><a href="tqtable.html#setPixmap">setPixmap</a>( i, 1, pix ); + table-><a href="tqtable.html#setText">setText</a>( i, 1, color.<a href="tqcolor.html#name">name</a>() ); <a href="tqcombobox.html">TQComboBox</a> *combobox = new <a href="tqcombobox.html">TQComboBox</a>; for ( int j = 0; j < MAX_PATTERNS; ++j ) combobox-><a href="tqcombobox.html#insertItem">insertItem</a>( patterns[j] ); <a name="x2603"></a> combobox-><a href="tqcombobox.html#setCurrentItem">setCurrentItem</a>( element.valuePattern() - 1 ); - <a name="x2618"></a> table-><a href="ntqtable.html#setCellWidget">setCellWidget</a>( i, 2, combobox ); + <a name="x2618"></a> table-><a href="tqtable.html#setCellWidget">setCellWidget</a>( i, 2, combobox ); - table-><a href="ntqtable.html#setText">setText</a>( i, 3, element.label() ); + table-><a href="tqtable.html#setText">setText</a>( i, 3, element.label() ); color = element.labelColor(); <a name="x2606"></a> pix.<a href="tqpixmap.html#fill">fill</a>( color ); - <a name="x2623"></a> table-><a href="ntqtable.html#setPixmap">setPixmap</a>( i, 4, pix ); - <a name="x2624"></a><a name="x2600"></a> table-><a href="ntqtable.html#setText">setText</a>( i, 4, color.<a href="tqcolor.html#name">name</a>() ); + <a name="x2623"></a> table-><a href="tqtable.html#setPixmap">setPixmap</a>( i, 4, pix ); + <a name="x2624"></a><a name="x2600"></a> table-><a href="tqtable.html#setText">setText</a>( i, 4, color.<a href="tqcolor.html#name">name</a>() ); </pre> <p> For each element in the element vector we must populate the table. <p> If the element is valid we write its value in the first column (column @@ -241,12 +241,12 @@ create a blank pixmap of that size. color; we then set the color cell to display this pixmap. We need to be able to read back the color later (e.g. if the user changes it). One way of doing this would be to examine a pixel in the pixmap; -another way would be to subclass <a href="qtableitem.html">TQTableItem</a> (in a similar way to our +another way would be to subclass <a href="tqtableitem.html">TQTableItem</a> (in a similar way to our CanvasText subclass) and store the color there. But we've taken a simpler route: we set the cell's text to the name of the color. <p> Next we populate the pattern combobox with the patterns. We will use the position of the chosen pattern in the combobox to determine which -pattern the user has selected. <a href="ntqtable.html">TQTable</a> can make use of <a href="tqcombotableitem.html">TQComboTableItem</a> +pattern the user has selected. <a href="tqtable.html">TQTable</a> can make use of <a href="tqcombotableitem.html">TQComboTableItem</a> items; but these only support text, so we use setCellWidget() to insert <a href="tqcombobox.html">TQComboBox</a>'s into the table instead. <p> Next we insert the element's label. Finally we set the label color in @@ -265,13 +265,13 @@ we enable the colorPushButton; otherwise we disable it. { if ( col == 0 ) { bool ok; - <a name="x2625"></a> double d = table-><a href="ntqtable.html#text">text</a>( row, col ).toDouble( &ok ); + <a name="x2625"></a> double d = table-><a href="tqtable.html#text">text</a>( row, col ).toDouble( &ok ); if ( ok && d > EPSILON ) - table-><a href="ntqtable.html#setText">setText</a>( + table-><a href="tqtable.html#setText">setText</a>( row, col, TQString( "%1" ).arg( d, 0, 'f', m_decimalPlaces ) ); - else if ( !table-><a href="ntqtable.html#text">text</a>( row, col ).isEmpty() ) - table-><a href="ntqtable.html#setText">setText</a>( row, col, table-><a href="ntqtable.html#text">text</a>( row, col ) + "?" ); + else if ( !table-><a href="tqtable.html#text">text</a>( row, col ).isEmpty() ) + table-><a href="tqtable.html#setText">setText</a>( row, col, table-><a href="tqtable.html#text">text</a>( row, col ) + "?" ); } } </pre> @@ -279,7 +279,7 @@ we enable the colorPushButton; otherwise we disable it. number of decimal places, or indicate that it is invalid. <p> <pre> void SetDataForm::setColor() { - <a name="x2615"></a><a name="x2614"></a> setColor( table-><a href="ntqtable.html#currentRow">currentRow</a>(), table-><a href="ntqtable.html#currentColumn">currentColumn</a>() ); + <a name="x2615"></a><a name="x2614"></a> setColor( table-><a href="tqtable.html#currentRow">currentRow</a>(), table-><a href="tqtable.html#currentColumn">currentColumn</a>() ); table-><a href="tqwidget.html#setFocus">setFocus</a>(); } </pre> @@ -291,13 +291,13 @@ function and put the focus back into the table. return; <a name="x2601"></a> <a href="tqcolor.html">TQColor</a> color = TQColorDialog::<a href="tqcolordialog.html#getColor">getColor</a>( - TQColor( table-><a href="ntqtable.html#text">text</a>( row, col ) ), + TQColor( table-><a href="tqtable.html#text">text</a>( row, col ) ), this, "color dialog" ); <a name="x2599"></a> if ( color.<a href="tqcolor.html#isValid">isValid</a>() ) { - <a name="x2617"></a> <a href="tqpixmap.html">TQPixmap</a> pix = table-><a href="ntqtable.html#pixmap">pixmap</a>( row, col ); + <a name="x2617"></a> <a href="tqpixmap.html">TQPixmap</a> pix = table-><a href="tqtable.html#pixmap">pixmap</a>( row, col ); pix.<a href="tqpixmap.html#fill">fill</a>( color ); - table-><a href="ntqtable.html#setPixmap">setPixmap</a>( row, col, pix ); - table-><a href="ntqtable.html#setText">setText</a>( row, col, color.<a href="tqcolor.html#name">name</a>() ); + table-><a href="tqtable.html#setPixmap">setPixmap</a>( row, col, pix ); + table-><a href="tqtable.html#setText">setText</a>( row, col, color.<a href="tqcolor.html#name">name</a>() ); } } </pre> @@ -310,16 +310,16 @@ color and set the cell's text to the new color's name. bool ok; for ( int i = 0; i < ChartForm::MAX_ELEMENTS; ++i ) { Element &element = (*m_elements)[i]; - double d = table-><a href="ntqtable.html#text">text</a>( i, 0 ).toDouble( &ok ); + double d = table-><a href="tqtable.html#text">text</a>( i, 0 ).toDouble( &ok ); if ( ok ) element.setValue( d ); else element.setValue( Element::INVALID ); - element.setValueColor( TQColor( table-><a href="ntqtable.html#text">text</a>( i, 1 ) ) ); + element.setValueColor( TQColor( table-><a href="tqtable.html#text">text</a>( i, 1 ) ) ); element.setValuePattern( - <a name="x2611"></a> ((TQComboBox*)table-><a href="ntqtable.html#cellWidget">cellWidget</a>( i, 2 ))->currentItem() + 1 ); - element.setLabel( table-><a href="ntqtable.html#text">text</a>( i, 3 ) ); - element.setLabelColor( TQColor( table-><a href="ntqtable.html#text">text</a>( i, 4 ) ) ); + <a name="x2611"></a> ((TQComboBox*)table-><a href="tqtable.html#cellWidget">cellWidget</a>( i, 2 ))->currentItem() + 1 ); + element.setLabel( table-><a href="tqtable.html#text">text</a>( i, 3 ) ); + element.setLabelColor( TQColor( table-><a href="tqtable.html#text">text</a>( i, 4 ) ) ); } TQDialog::<a href="tqdialog.html#accept">accept</a>(); |