Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTabWidget & co.
QtWS25 Last Chance

QTabWidget & co.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rohaase
    wrote on last edited by
    #1

    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 !!

    I am a newbie in C++ - so be kind ;=)

    1 Reply Last reply
    0
    • frederikF Offline
      frederikF Offline
      frederik
      wrote on last edited by
      #2

      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).

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rohaase
        wrote on last edited by
        #3

        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 ...

        I am a newbie in C++ - so be kind ;=)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved