Important: Please read the Qt Code of Conduct -

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 ";
    case Qt::RightButton:
    str += " RIGHT ";
    str += " unbekannt ";
    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


    mousePresseEvent is an event handler not a filter.

    The documentation contains a good example "here":

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

Log in to reply