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. How to detect when icon clicked in item delegate ?
Forum Updated to NodeBB v4.3 + New Features

How to detect when icon clicked in item delegate ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 4.1k Views 1 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.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    Hi
    i have QTableView item delegate , which there i construct text and 2 icons one for delete the table row and one to do some other action .
    my question is how to detect and trigger function when my mouse is click on one of the icons in the item delegate ?
    do i need to post code ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You should reimplement the editorEvent() virtual method from [[doc:QAbstractItemDelegate]]. From the documentation:
      [quote]Mouse events are sent to editorEvent() even if they don't start editing of the item. This can, for instance, be useful if you wish to open a context menu when the right mouse button is pressed on an item.[/quote]
      So, you can handle mouse events from this method. It is up to you to determine if a click is on an icon or not.

      For communication of the event, I would give the delegate one or more signals (that include a QModelIndex as an argument) that communicate the triggering of the event.

      1 Reply Last reply
      1

      • Login

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