summaryrefslogtreecommitdiffstats
path: root/doc/html/chart-setdataform-cpp.html
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
committerTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /doc/html/chart-setdataform-cpp.html
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'doc/html/chart-setdataform-cpp.html')
-rw-r--r--doc/html/chart-setdataform-cpp.html250
1 files changed, 250 insertions, 0 deletions
diff --git a/doc/html/chart-setdataform-cpp.html b/doc/html/chart-setdataform-cpp.html
new file mode 100644
index 000000000..9b400de6c
--- /dev/null
+++ b/doc/html/chart-setdataform-cpp.html
@@ -0,0 +1,250 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:15 -->
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>chart/setdataform.cpp Example File</title>
+<style type="text/css"><!--
+fn { margin-left: 1cm; text-indent: -1cm; }
+a:link { color: #004faf; text-decoration: none }
+a:visited { color: #672967; text-decoration: none }
+body { background: #ffffff; color: black; }
+--></style>
+</head>
+<body>
+
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+<tr bgcolor="#E5E5E5">
+<td valign=center>
+ <a href="index.html">
+<font color="#004faf">Home</font></a>
+ | <a href="classes.html">
+<font color="#004faf">All&nbsp;Classes</font></a>
+ | <a href="mainclasses.html">
+<font color="#004faf">Main&nbsp;Classes</font></a>
+ | <a href="annotated.html">
+<font color="#004faf">Annotated</font></a>
+ | <a href="groups.html">
+<font color="#004faf">Grouped&nbsp;Classes</font></a>
+ | <a href="functions.html">
+<font color="#004faf">Functions</font></a>
+</td>
+<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>chart/setdataform.cpp Example File</h1>
+
+
+<pre>#include "setdataform.h"
+#include "chartform.h"
+
+#include &lt;<a href="qcolordialog-h.html">qcolordialog.h</a>&gt;
+#include &lt;<a href="qcombobox-h.html">qcombobox.h</a>&gt;
+#include &lt;<a href="qlayout-h.html">qlayout.h</a>&gt;
+#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;
+#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;
+#include &lt;<a href="qtable-h.html">qtable.h</a>&gt;
+
+#include "images/pattern01.xpm"
+#include "images/pattern02.xpm"
+#include "images/pattern03.xpm"
+#include "images/pattern04.xpm"
+#include "images/pattern05.xpm"
+#include "images/pattern06.xpm"
+#include "images/pattern07.xpm"
+#include "images/pattern08.xpm"
+#include "images/pattern09.xpm"
+#include "images/pattern10.xpm"
+#include "images/pattern11.xpm"
+#include "images/pattern12.xpm"
+#include "images/pattern13.xpm"
+#include "images/pattern14.xpm"
+
+const int MAX_PATTERNS = 14;
+
+
+<a name="f178"></a>SetDataForm::SetDataForm( ElementVector *elements, int decimalPlaces,
+ <a href="qwidget.html">TQWidget</a>* parent, const char* name,
+ bool modal, WFlags f )
+ : <a href="qdialog.html">TQDialog</a>( parent, name, modal, f )
+
+{
+ m_elements = elements;
+ m_decimalPlaces = decimalPlaces;
+
+ <a href="qwidget.html#setCaption">setCaption</a>( "Chart -- Set Data" );
+ <a href="qwidget.html#resize">resize</a>( 540, 440 );
+
+ tableButtonBox = new <a href="qvboxlayout.html">TQVBoxLayout</a>( this, 11, 6, "table button box layout" );
+
+ table = new <a href="qtable.html">TQTable</a>( this, "data table" );
+ table-&gt;<a href="qtable.html#setNumCols">setNumCols</a>( 5 );
+ table-&gt;<a href="qtable.html#setNumRows">setNumRows</a>( ChartForm::MAX_ELEMENTS );
+ table-&gt;<a href="qtable.html#setColumnReadOnly">setColumnReadOnly</a>( 1, TRUE );
+ table-&gt;<a href="qtable.html#setColumnReadOnly">setColumnReadOnly</a>( 2, TRUE );
+ table-&gt;<a href="qtable.html#setColumnReadOnly">setColumnReadOnly</a>( 4, TRUE );
+ table-&gt;<a href="qtable.html#setColumnWidth">setColumnWidth</a>( 0, 80 );
+ table-&gt;<a href="qtable.html#setColumnWidth">setColumnWidth</a>( 1, 60 ); // Columns 1 and 4 must be equal
+ table-&gt;<a href="qtable.html#setColumnWidth">setColumnWidth</a>( 2, 60 );
+ table-&gt;<a href="qtable.html#setColumnWidth">setColumnWidth</a>( 3, 200 );
+ table-&gt;<a href="qtable.html#setColumnWidth">setColumnWidth</a>( 4, 60 );
+ <a href="qheader.html">TQHeader</a> *th = table-&gt;<a href="qtable.html#horizontalHeader">horizontalHeader</a>();
+ th-&gt;<a href="qheader.html#setLabel">setLabel</a>( 0, "Value" );
+ th-&gt;<a href="qheader.html#setLabel">setLabel</a>( 1, "Color" );
+ th-&gt;<a href="qheader.html#setLabel">setLabel</a>( 2, "Pattern" );
+ th-&gt;<a href="qheader.html#setLabel">setLabel</a>( 3, "Label" );
+ th-&gt;<a href="qheader.html#setLabel">setLabel</a>( 4, "Color" );
+ tableButtonBox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( table );
+
+ buttonBox = new <a href="qhboxlayout.html">TQHBoxLayout</a>( 0, 0, 6, "button box layout" );
+
+ colorPushButton = new <a href="qpushbutton.html">TQPushButton</a>( this, "color button" );
+ colorPushButton-&gt;<a href="qbutton.html#setText">setText</a>( "&amp;Color..." );
+ colorPushButton-&gt;<a href="qwidget.html#setEnabled">setEnabled</a>( FALSE );
+ buttonBox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( colorPushButton );
+
+ <a href="qspaceritem.html">TQSpacerItem</a> *spacer = new <a href="qspaceritem.html">TQSpacerItem</a>( 0, 0, TQSizePolicy::Expanding,
+ TQSizePolicy::Minimum );
+ buttonBox-&gt;<a href="qboxlayout.html#addItem">addItem</a>( spacer );
+
+ okPushButton = new <a href="qpushbutton.html">TQPushButton</a>( this, "ok button" );
+ okPushButton-&gt;<a href="qbutton.html#setText">setText</a>( "OK" );
+ okPushButton-&gt;<a href="qpushbutton.html#setDefault">setDefault</a>( TRUE );
+ buttonBox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( okPushButton );
+
+ cancelPushButton = new <a href="qpushbutton.html">TQPushButton</a>( this, "cancel button" );
+ cancelPushButton-&gt;<a href="qbutton.html#setText">setText</a>( "Cancel" );
+ cancelPushButton-&gt;<a href="qbutton.html#setAccel">setAccel</a>( Key_Escape );
+ buttonBox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( cancelPushButton );
+
+ tableButtonBox-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( buttonBox );
+
+ <a href="qobject.html#connect">connect</a>( table, SIGNAL( <a href="qtable.html#clicked">clicked</a>(int,int,int,const <a href="qpoint.html">TQPoint</a>&amp;) ),
+ this, SLOT( setColor(int,int) ) );
+ <a href="qobject.html#connect">connect</a>( table, SIGNAL( <a href="qtable.html#currentChanged">currentChanged</a>(int,int) ),
+ this, SLOT( currentChanged(int,int) ) );
+ <a href="qobject.html#connect">connect</a>( table, SIGNAL( <a href="qtable.html#valueChanged">valueChanged</a>(int,int) ),
+ this, SLOT( valueChanged(int,int) ) );
+ <a href="qobject.html#connect">connect</a>( colorPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( setColor() ) );
+ <a href="qobject.html#connect">connect</a>( okPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( <a href="qdialog.html#accept">accept</a>() ) );
+ <a href="qobject.html#connect">connect</a>( cancelPushButton, SIGNAL( <a href="qbutton.html#clicked">clicked</a>() ), this, SLOT( <a href="qdialog.html#reject">reject</a>() ) );
+
+ TQPixmap patterns[MAX_PATTERNS];
+ patterns[0] = TQPixmap( pattern01 );
+ patterns[1] = TQPixmap( pattern02 );
+ patterns[2] = TQPixmap( pattern03 );
+ patterns[3] = TQPixmap( pattern04 );
+ patterns[4] = TQPixmap( pattern05 );
+ patterns[5] = TQPixmap( pattern06 );
+ patterns[6] = TQPixmap( pattern07 );
+ patterns[7] = TQPixmap( pattern08 );
+ patterns[8] = TQPixmap( pattern09 );
+ patterns[9] = TQPixmap( pattern10 );
+ patterns[10] = TQPixmap( pattern11 );
+ patterns[11] = TQPixmap( pattern12 );
+ patterns[12] = TQPixmap( pattern13 );
+ patterns[13] = TQPixmap( pattern14 );
+
+ <a href="qrect.html">TQRect</a> rect = table-&gt;<a href="qtable.html#cellRect">cellRect</a>( 0, 1 );
+ <a href="qpixmap.html">TQPixmap</a> pix( rect.<a href="qrect.html#width">width</a>(), rect.<a href="qrect.html#height">height</a>() );
+
+ for ( int i = 0; i &lt; ChartForm::MAX_ELEMENTS; ++i ) {
+ Element element = (*m_elements)[i];
+
+ if ( element.isValid() )
+ table-&gt;<a href="qtable.html#setText">setText</a>(
+ i, 0,
+ TQString( "%1" ).arg( element.value(), 0, 'f',
+ m_decimalPlaces ) );
+
+ <a href="qcolor.html">TQColor</a> color = element.valueColor();
+ pix.<a href="qpixmap.html#fill">fill</a>( color );
+ table-&gt;<a href="qtable.html#setPixmap">setPixmap</a>( i, 1, pix );
+ table-&gt;<a href="qtable.html#setText">setText</a>( i, 1, color.<a href="qcolor.html#name">name</a>() );
+
+ <a href="qcombobox.html">TQComboBox</a> *combobox = new <a href="qcombobox.html">TQComboBox</a>;
+ for ( int j = 0; j &lt; MAX_PATTERNS; ++j )
+ combobox-&gt;<a href="qcombobox.html#insertItem">insertItem</a>( patterns[j] );
+ combobox-&gt;<a href="qcombobox.html#setCurrentItem">setCurrentItem</a>( element.valuePattern() - 1 );
+ table-&gt;<a href="qtable.html#setCellWidget">setCellWidget</a>( i, 2, combobox );
+
+ table-&gt;<a href="qtable.html#setText">setText</a>( i, 3, element.label() );
+
+ color = element.labelColor();
+ pix.<a href="qpixmap.html#fill">fill</a>( color );
+ table-&gt;<a href="qtable.html#setPixmap">setPixmap</a>( i, 4, pix );
+ table-&gt;<a href="qtable.html#setText">setText</a>( i, 4, color.<a href="qcolor.html#name">name</a>() );
+ }
+
+}
+
+
+void <a name="f179"></a>SetDataForm::currentChanged( int, int col )
+{
+ colorPushButton-&gt;<a href="qwidget.html#setEnabled">setEnabled</a>( col == 1 || col == 4 );
+}
+
+
+void <a name="f180"></a>SetDataForm::valueChanged( int row, int col )
+{
+ if ( col == 0 ) {
+ bool ok;
+ double d = table-&gt;<a href="qtable.html#text">text</a>( row, col ).toDouble( &amp;ok );
+ if ( ok &amp;&amp; d &gt; EPSILON )
+ table-&gt;<a href="qtable.html#setText">setText</a>(
+ row, col, TQString( "%1" ).arg(
+ d, 0, 'f', m_decimalPlaces ) );
+ else if ( !table-&gt;<a href="qtable.html#text">text</a>( row, col ).isEmpty() )
+ table-&gt;<a href="qtable.html#setText">setText</a>( row, col, table-&gt;<a href="qtable.html#text">text</a>( row, col ) + "?" );
+ }
+}
+
+
+void <a name="f181"></a>SetDataForm::setColor()
+{
+ setColor( table-&gt;<a href="qtable.html#currentRow">currentRow</a>(), table-&gt;<a href="qtable.html#currentColumn">currentColumn</a>() );
+ table-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
+}
+
+
+void SetDataForm::setColor( int row, int col )
+{
+ if ( !( col == 1 || col == 4 ) )
+ return;
+
+ <a href="qcolor.html">TQColor</a> color = TQColorDialog::<a href="qcolordialog.html#getColor">getColor</a>(
+ TQColor( table-&gt;<a href="qtable.html#text">text</a>( row, col ) ),
+ this, "color dialog" );
+ if ( color.<a href="qcolor.html#isValid">isValid</a>() ) {
+ <a href="qpixmap.html">TQPixmap</a> pix = table-&gt;<a href="qtable.html#pixmap">pixmap</a>( row, col );
+ pix.<a href="qpixmap.html#fill">fill</a>( color );
+ table-&gt;<a href="qtable.html#setPixmap">setPixmap</a>( row, col, pix );
+ table-&gt;<a href="qtable.html#setText">setText</a>( row, col, color.<a href="qcolor.html#name">name</a>() );
+ }
+}
+
+
+void SetDataForm::<a href="qdialog.html#accept">accept</a>()
+{
+ bool ok;
+ for ( int i = 0; i &lt; ChartForm::MAX_ELEMENTS; ++i ) {
+ Element &amp;element = (*m_elements)[i];
+ double d = table-&gt;<a href="qtable.html#text">text</a>( i, 0 ).toDouble( &amp;ok );
+ if ( ok )
+ element.setValue( d );
+ else
+ element.setValue( Element::INVALID );
+ element.setValueColor( TQColor( table-&gt;<a href="qtable.html#text">text</a>( i, 1 ) ) );
+ element.setValuePattern(
+ ((TQComboBox*)table-&gt;<a href="qtable.html#cellWidget">cellWidget</a>( i, 2 ))-&gt;currentItem() + 1 );
+ element.setLabel( table-&gt;<a href="qtable.html#text">text</a>( i, 3 ) );
+ element.setLabelColor( TQColor( table-&gt;<a href="qtable.html#text">text</a>( i, 4 ) ) );
+ }
+
+ TQDialog::<a href="qdialog.html#accept">accept</a>();
+}
+</pre><!-- eof -->
+<p><address><hr><div align=center>
+<table width=100% cellspacing=0 border=0><tr>
+<td>Copyright &copy; 2007
+<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
+<td align=right><div align=right>TQt 3.3.8</div>
+</table></div></address></body>
+</html>