Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How to detect when icon clicked in item delegate ?

    General and Desktop
    2
    2
    3724
    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.
    • U
      umen242 last edited by

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

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