[SOLVED} QTableWidget's header item is not visible, after using viewport...

  • I have used viewport to get the mouse click event on my tableWidget , but my vertical header & Horizontal headers are not getting
    Visible after using viewPort().

    CTestDlg::CTestDlg(QWidget *parent) :
    ui(new Ui::CTestDlg)

    ui->tableWidget->horizontalHeader()->setVisible( true );
    ui->tableWidget->verticalHeader()->setVisible( true );
    ui->tableWidget->setMouseTracking( true );
    ui->tableWidget->viewport()->installEventFilter( this ); //After using this line..i am not able to see my TABLE HEADER 


    bool CTestDlg::eventFilter(QObject *object, QEvent *event)
    if( event->type() == QEvent::MouseButtonPress && object == ui->tableWidget->viewport() )
    QMouseEvent mouseEvent = static_cast <QMouseEvent>( event );
    QMessageBox msg;
    msg.setText("TABLE WIDGET IS PRESSED");



    Please let me know whether i am using anything wrong on this??

    1. You must return value from eventFilter method.
    2. And you must pass the event on to the parent class if you not processed event
      @return QDialog::eventFilter(object, event);@

  • Thanks Vass..its working fine..
    Thanks for your valuable inputs..

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.