QTabWidget & co.



  • Hi all,

    I do not understand my mistake here ..

    @void QMyTabWidget::mousePressEvent(QMouseEvent *event)
    {
    QString str = "Mousebutton ";
    int clickpos = -1; // for later use
    switch (event->button())
    {
    case Qt::LeftButton:
    str += " LEFT ";
    break;
    case Qt::RightButton:
    str += " RIGHT ";
    break;
    default:
    str += " unbekannt ";
    break;
    }
    qDebug() << " pressed";
    qDebug() << "Tab " << clickpos << " clicked"; // for later use
    }
    @
    In this eventHandler i only get right - clicks .. which produce debug text.
    but no Tab changeing ..

    Left clicks change the Tab, but i got no text ..

    Please help!!!

    Any Questions ?? .. call me !!



  • The left clicks are handled by the QTabBar inside the tab widget, so if you want to handle them you need to do it there (or install an event filter).



  • Hey, Thanks for your answer !!

    Can you help me ( I am newbie ) and post me some code snippets how to handle this ? Because I thougt the eventMousePress is the eventFilter ...


  • Lifetime Qt Champion

    Hi,

    mousePresseEvent is an event handler not a filter.

    The documentation contains a good example "here":http://qt-project.org/doc/qt-5/qobject.html#eventFilter

    Like frederik said, you should apply the filter on the QTabBar, not the QTabWidget


Log in to reply
 

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