Originally Posted by
soumyadeep_pan
Can any body help me....thank in advance ....
I got the solution for the problem ... sorry for posting already solved problems.... here is my code for example, please post if any thing wrong ... thanks in advance ....
/*** Float Table Item header file ****/
class FloatTableItem : public QTableItem
{
public :
FloatTableItem
( QTable
* in_qTable, EditType in_Et,
const QString & in_strText
);
virtual QWidget * createEditor
() const ;
void setContentFromEditor
( QWidget *w
);
virtual int rtti() const;
};
/*** Float Table Item header file ****/
/*** Float Table Item implementation .cpp file ****/
FloatTableItem
::FloatTableItem ( QTable
* in_qTable, EditType in_Et,
const QString & in_strText
) : QTableItem
(in_qTable, in_Et, in_strText
){
return;
}
QWidget* FloatTableItem
::createEditor() const {
le_Temp->setMaxLength(6);
if (le_Temp)
{
QRegExp rx
( "[0-9]{0,3}[.]?[0-9]{0,2}");
le_Temp->setValidator(validator);
}
return le_Temp;
}
void FloatTableItem
::setContentFromEditor( QWidget *in_qWidget
) {
if ( in_qWidget->inherits( "QLineEdit" ) )
setText
( ( (QLineEdit*)in_qWidget
)->text
() );
else
QTableItem::setContentFromEditor( in_qWidget );
}
int FloatTableItem::rtti() const
{
return 32355;
}
/*** Float Table Item implementation .cpp file ****/
/*** Float Table Item header file ****/
class FloatTableItem : public QTableItem
{
public :
FloatTableItem ( QTable * in_qTable, EditType in_Et, const QString & in_strText );
virtual QWidget * createEditor () const ;
void setContentFromEditor( QWidget *w );
virtual int rtti() const;
};
/*** Float Table Item header file ****/
/*** Float Table Item implementation .cpp file ****/
FloatTableItem::FloatTableItem ( QTable * in_qTable, EditType in_Et, const QString & in_strText ) : QTableItem (in_qTable, in_Et, in_strText)
{
return;
}
QWidget* FloatTableItem::createEditor() const
{
QLineEdit* le_Temp = (QLineEdit *) (QTableItem::createEditor());
le_Temp->setMaxLength(6);
if (le_Temp)
{
QRegExp rx( "[0-9]{0,3}[.]?[0-9]{0,2}");
QValidator* validator = new QRegExpValidator( rx, le_Temp );
le_Temp->setValidator(validator);
}
return le_Temp;
}
void FloatTableItem::setContentFromEditor( QWidget *in_qWidget )
{
if ( in_qWidget->inherits( "QLineEdit" ) )
setText( ( (QLineEdit*)in_qWidget )->text() );
else
QTableItem::setContentFromEditor( in_qWidget );
}
int FloatTableItem::rtti() const
{
return 32355;
}
/*** Float Table Item implementation .cpp file ****/
To copy to clipboard, switch view to plain text mode
Bookmarks