Nominate our 2022 Qt Champions!

Activated signal in QTreeView

  • When i make connection of QTreeView activated(const QModelIndex &) to my slot:
    @ connect(m_ui->treeView, SIGNAL(activated(QModelIndex)), this, SLOT(onActivated(QModelIndex)));@
    and put a breakpoint in slot I don't get there. Click or double-click on item only shows delegate but don't get to slot. When i replace signal activated by signal click it works perfect. So when signal activated emits from QTreeView ?
    In assistant i find that :

    bq. This signal is emitted when the item specified by index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.

    And I need to catch pre-editing of my item(the moment when I call delegate) and replace old delegate by new one in my slot.

  • The activated signal is working fine for me, I think it depends on how you are interpreting "activated", this is not the same as "selected". As per the quote you supplied activation is different for each platform; on windows for example it seems to fire when I double click an item. I am not sure what functionality you are after specifically but if you are after a selection change then you could try subclassing QTreeView and override the selectionChanged slot.

  • It don't work on windows platform if double-clicking on item. I know that this is not the same as "selected", but with selected (click signal) it works, I mean it enters my slot, but if I use activated signal it never get there (even when I enter item, change value and press "Enter" key). So I need to know when the signal activated is emitted in my case? Maybe it don't work because I use item delegate ?

Log in to reply