Results 1 to 3 of 3

Thread: Q3Table event filter problem

  1. #1
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Q3Table event filter problem

    I m porting qt3 codes to qt4.
    Here I have a class TableGrid which inherits Q3Table (inherit QTable originally)

    Qt Code:
    1. class TableGrid : public Q3Table {
    2. public:
    3. MyTableGrid( int numRows, int numCols, QWidget* parent, const char* name);
    4. void paintCell(QPainter *p, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg);
    5. };
    To copy to clipboard, switch view to plain text mode 

    and I used this TableGrid in another class MyTable:
    Qt Code:
    1. class MyTable : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. ...
    7. ...
    8. TableGrid* tbl; // Table
    9. ...
    10. ...
    11. ...
    12. }
    To copy to clipboard, switch view to plain text mode 

    And I called
    Qt Code:
    1. 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.

    Qt Code:
    1. bool MyTable::eventFilter ( QObject * obj, QEvent * e ){
    2. bool retval = false;
    3. if( QString(obj->name())==QString("tbl") )
    4. {
    5. if( e->type()==QEvent::Resize )
    6. {
    7. configTable();
    8. retval = true;
    9. }
    10. else if( e->type()==QEvent::MouseButtonPress )
    11. {
    12. tbl_mousePress();
    13. retval = true;
    14. }
    15. }
    16. return retval;
    17. }
    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

  2. #2
    Join Date
    May 2008
    Posts
    58
    Thanks
    2

    Default Re: Q3Table event filter problem

    Could you try:

    tbl->viewport()->installEventFilter( this );

  3. #3
    Join Date
    Jun 2008
    Posts
    64
    Thanks
    7
    Qt products
    Qt3 Qt4

    Default Re: Q3Table event filter problem

    Thanks!
    It works~

    But what's the difference of that viewport?
    And is that in QT4 the mouse related event will not be filtered?

Similar Threads

  1. QDockWidget-title
    By moowy in forum Qt Programming
    Replies: 18
    Last Post: 23rd April 2014, 20:13
  2. Q3Table performance problem
    By batileon in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2008, 15:32
  3. Problem in MouseMove Event
    By Gamalof in forum Qt Programming
    Replies: 4
    Last Post: 17th June 2008, 20:24
  4. Replies: 1
    Last Post: 16th October 2007, 22:41
  5. event problem
    By windkracht8 in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2006, 11:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.