Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    3
    6
    2851
    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.
    • jerome_isAviable
      jerome_isAviable last edited by

      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 Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

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

          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 Reply Quote 0
          • dheerendra
            dheerendra Qt Champions 2022 last edited by

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

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

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