Important: Please read the Qt Code of Conduct -

The QtreeView selection row freeze

    • here is the conditions: i have a qtreeview promoted and a custom model (QAbstractItemModel) with a specific class for items. And from the promoted QtreeView class, i have a mouseReleaseEvent() slot create for catch right and left click release events from the viewport of the view. I use it by opene a popup window and emit signals that a DialogBox use to connect to some slots (4 signals, one on right click and 3 on menu actions from popup menu chooses)... each of them do actions for populate the view by the model.
      The view is well populate, dataChanged signal from model is only call (1 time) when i edit an item. i can add childs item too by this way... and the model at the end will well populate a database from datas collected/created.

    • problem: i populate the view with for exemple 5 items (childs or not) and select a line, and an other, ect... and quickly, the view freeze on selection by mouse click... the signals works again, but give back all the time the last selection from freeze time... slots are well mounted and i can follow to populate (but only from the blocked index). If i delete a row (one of my 3 options menu popup), the view unfreeze... and go back freeze the same way after some selections.

    • what's works / what i try : debugger never show me nothing, but by debugger, the view need much more selections before freeze (3 times more). The Valgrind tools analyze not show me nothing anormal (i think), but again... need more actions selections to freeze than debug mode.... And then, if i use the slot called by the signal emit from the left release mouse click event for tell the view to setCurrentIndex to current index from the event click, this works fine... but i can not more open the hierarchy tree by click on the arrows.... I never find where this come from.

    • any idea ? what can be make freeze a view ? and/or what i can do (which is the code) for tell the view to open tree when i click on the arrow (because this will do the job better than the automatic strange job do the view... when it want...) ? OR what i can do for find where come from the problem ?

  • Lifetime Qt Champion


    Are sure you are doing the connections only once ?
    Did you look at QWidget::customContextMenuRequested for your purpose ?

  • Yes SGaist, i'm sure.
    here is my promote class of my treeview:

    and here is my model of the same view:

    and here is my item class (Classeur):

    and here my mainwindow where the view is and where i connect signal to slots:

    i go looking what you tell me for read what this talk about...

  • Hi,
    Has there been a solution for this issue? I am facing a similar problem; the current index freezes while doing multiple left clicks on the tree index.

    I am doing multiple selections using mouse release event for left clicks. All default signals are executed. I wonder how could I debug this issue?

Log in to reply