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. Any way to stop QListView reacting to ANY mouse button without subclassing?

Any way to stop QListView reacting to ANY mouse button without subclassing?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 337 Views 2 Watching
  • 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.
  • ZueukZ Offline
    ZueukZ Offline
    Zueuk
    wrote on last edited by
    #1

    It seems quite counter-intuitive to me, that QListView treats any mouse button as the left button - for example, in most applications, middle mouse button is used to scroll the view, but QListView reacts with selecting an item. And it does the same if I press mouse buttons 4 and 5, which is even more unnecessary thing to do.

    Of course I could derive my own class and override mousePressEvent - but is there another option? Something in the QAbstractItemView perhaps?

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

      Hi,

      You can use an event filter for example.

      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
      3
      • ZueukZ Offline
        ZueukZ Offline
        Zueuk
        wrote on last edited by
        #3

        Hmm, this still feels a bit weird, but at least solves the problem.

        One thing to add: in case of QListView or QTreeView, the event filter should be installed not on the widget itself, but on its viewport.

        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