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
);
};
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);
};
To copy to clipboard, switch view to plain text mode
and I used this TableGrid in another class MyTable:
{
Q_OBJECT
public:
...
...
TableGrid* tbl; // Table
...
...
...
}
class MyTable : public QWidget
{
Q_OBJECT
public:
...
...
TableGrid* tbl; // Table
...
...
...
}
To copy to clipboard, switch view to plain text mode
And I called
tbl->installEventFilter( this );
tbl->installEventFilter( this );
To copy to clipboard, switch view to plain text mode
to set the event filter.
The objective is to filter the mouse button pressed event signal.
bool retval = false;
{
if( e
->type
()==QEvent::Resize ) {
configTable();
retval = true;
}
else if( e
->type
()==QEvent::MouseButtonPress ) {
tbl_mousePress();
retval = true;
}
}
return retval;
}
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;
}
To copy to clipboard, switch view to plain text mode
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
Bookmarks