Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    QTabWidget & co.

    General and Desktop
    3
    4
    869
    Loading More Posts
    • 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
      rohaase last edited by

      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 Reply Quote 0
      • frederik
        frederik last edited by

        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 Reply Quote 0
        • R
          rohaase last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • First post
              Last post