How do I connect to an event of line edit completion/exit and catch it in a QTreeView?



  • So I have a tree view that updates a panel of content after selection change, however I'm running into an issue of after line edit it is updating the name of that item, and it's not properly saving the change to that item and reopening it with the new info, in fact it completely looses context and its not even open anymore. Is there a way for me to catch the line edit event and call my own function?


  • Qt Champions 2016

    @lancelotrose
    Hello,
    You can intercept the line edit's events by installing an event filter, although I didn't quite catch what you're trying to do and why you need to do that.

    Kind regards.



  • @kshegunov Hi thanks that mostly fixed the issue need to do a little more debugging but was able to get a subevent type and handle it properly given one condition.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Something sounds fishy here. Looks like you are editing an entry in your QTreeView and that it doesn't get stored in your model, right ? If so, what model are you using ? Are you using a custom QStyledItemDelegate ?



  • @SGaist It's actually not originally my code base. They created objects that it refers to, but I'm not sure if they are actually dispatching/handling the signals correctly when the item is changed. So I know what the problem is whenever an item is changed it is released(which deletes the current existing model and returns a "updated/reverted" model at the same index), so the panel is still pointing to the old non-existent model, which happens to be at the same index, but they aren't necessarily catching the change and correctly updating the reference to the model when they change it in the tree, so I'm trying to fix that, adding the event listener and filtering events has helped allot, and I'm sure it's the solution I just haven't handled all plausible event cases yet, where these changes may occur.


  • Lifetime Qt Champion

    Sounds pretty crazy...



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.