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. Slot mouse event: right click / middle click... how to catch this ?

Slot mouse event: right click / middle click... how to catch this ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.3k 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.
  • jerome_isAviableJ Offline
    jerome_isAviableJ Offline
    jerome_isAviable
    wrote on last edited by
    #1

    Hi,
    I would like to be able to catch events like right and middle click mouse... but in the list of slot event in the QtDesigner, i can not see any option for do it. Also, search in the Qt doc is a big pain (except maybe if you know allready all the Qt code... but at this point, you not need the doc).

    Also, for now i need to use it inside two QTreeView (i have my own Model create for one, and an other one use QStandardItemModel). i would like to use it on a row (for exemple, right click on a row open a menu... by this way i could delete the row, and all the childs of the row).
    Same for middle click but on an item in the treeview call an other menu.

    Qt can do it easy ? and how to find usable/readable informations to learn this ? (QT-5.3.2 with C++)

    thanks for try to help.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Hope you got a chance to look at how to handle mouse events in Qt. Please look at QWidget virtual functions like mousePressEvent(....), mouseMoveEvent(...) etc. This should help you. You can't get these in Qt Designer as slots. You need to override these methods and handle these events.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • jerome_isAviableJ Offline
        jerome_isAviableJ Offline
        jerome_isAviable
        wrote on last edited by
        #3

        Ok thanks, i just read on QMouseEvent. surprise that this part of doc seems to be clear.

        has i can understand, i can enable it for the widget (i think QTreeView is a widget...) and reicept datas about the button clicked (and then create a condition test around this), and the x,y position inside the widget... with this position, i can search the item with indexAt(Qpos) inside my model.

        right ?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          ok. Just look at Model view programming documentation in Qt Assistant, look a the QTableView class which is QWidget. Look at SelectionModel class etc. All this together may help you on what you are trying to do.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • jerome_isAviableJ Offline
            jerome_isAviableJ Offline
            jerome_isAviable
            wrote on last edited by
            #5

            ok fine, this works perfectly.
            I try now to open a menu after catch it... i would post about this because it is not the same subject now.

            Thanks again.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nando76
              wrote on last edited by
              #6

              Also check: "virtual void contextMenuEvent(QContextMenuEvent * event)":http://doc-snapshot.qt-project.org/qt5-5.4/qwidget.html

              Greetings
              Nando

              [quote author="jerome_isAviable?" date="1420441651"]ok fine, this works perfectly.
              I try now to open a menu after catch it... i would post about this because it is not the same subject now.

              Thanks again.[/quote]

              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