batileon
27th August 2008, 03:26
I m porting qt3 codes to qt4.
Here I have a class TableGrid which inherits Q3Table (inherit QTable originally)
class TableGrid : public Q3Table {
public:
MyTableGrid( int numRows, int numCols, QWidget* parent, const char* name);
void paintCell(QPainter *p, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg);
};
and I used this TableGrid in another class MyTable:
class MyTable : public QWidget
{
Q_OBJECT
public:
...
...
TableGrid* tbl; // Table
...
...
...
}
And I called
tbl->installEventFilter( this );
to set the event filter.
The objective is to filter the mouse button pressed event signal.
bool MyTable::eventFilter ( QObject * obj, QEvent * e ){
bool retval = false;
if( QString(obj->name())==QString("tbl") )
{
if( e->type()==QEvent::Resize )
{
configTable();
retval = true;
}
else if( e->type()==QEvent::MouseButtonPress )
{
tbl_mousePress();
retval = true;
}
}
return retval;
}
This work in the past (QT3)
however I found that in QT4, the MouseButtonPress QEvent can no longer received when I click on the TableGrid.
Can anyone tell me what's going wrong??
Thanks a lot
Here I have a class TableGrid which inherits Q3Table (inherit QTable originally)
class TableGrid : public Q3Table {
public:
MyTableGrid( int numRows, int numCols, QWidget* parent, const char* name);
void paintCell(QPainter *p, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg);
};
and I used this TableGrid in another class MyTable:
class MyTable : public QWidget
{
Q_OBJECT
public:
...
...
TableGrid* tbl; // Table
...
...
...
}
And I called
tbl->installEventFilter( this );
to set the event filter.
The objective is to filter the mouse button pressed event signal.
bool MyTable::eventFilter ( QObject * obj, QEvent * e ){
bool retval = false;
if( QString(obj->name())==QString("tbl") )
{
if( e->type()==QEvent::Resize )
{
configTable();
retval = true;
}
else if( e->type()==QEvent::MouseButtonPress )
{
tbl_mousePress();
retval = true;
}
}
return retval;
}
This work in the past (QT3)
however I found that in QT4, the MouseButtonPress QEvent can no longer received when I click on the TableGrid.
Can anyone tell me what's going wrong??
Thanks a lot