Skip to content
QtWS25 Call for Papers
  • 0 Votes
    9 Posts

    I'm not understanding what is going on with your const or not. The slot CommitData() must not be const. Is it??

    Hmm, you mean you call it from CEditorDelegate::createEditor(), that is const, so its this is const, and you can't then use that for the slot object? Then I really don't know why it's OK for the connect() to actual slot but not to lambda (I suspect it's this issue, not because the new CommitData(QPushButton *btn) parameter....

    Is your CommitData() const? Doesn't look like it. If you made it const does that allow the connect()?

    I think this has crossed with your latest. I believe you show there you have found a way. I prefer the second one.

    Basically you have raised a "gotcha": createEditor() is const, and that prevents you from connecting a slot to this inside it, which is something one might well want to do. It (apparently) works when &CEditorDelegate::CommitData is passed on its own as a standalone argument, but not if you try a lambda with this->CommitData(). If the C++ super-experts here see this they might comment....

  • 0 Votes
    3 Posts

    @VRonin Aha, that has got to be it - thank you very much! Sounds like I just need to add a new eventfilter that does nothing but eat keypress events.

  • 0 Votes
    4 Posts

    I don't claim to understand why you want to do this. However, does the example (teh accepted solution to it) in, say, give you what you need? It's using to access the widget's state in an event. Seems a bit low-level to me, but maybe that's what you do....?

    Otherwise, I know the editor arranges to store the widget's value via editor widget's user property, see itself. Can you leverage that without actually calling setModelData()?

    Finally, returns the widget created for doing the editing. Can you put your own slots/call functions on that to recognise when it's edited and retrieve its value directly?

    If all else fails, what about looking at the source of the setModelData() method you do not want to use in page ? You can see there what it does (looks pretty simple), and decide what you want to do compared to that, since you don't want to call it yourself for whatever reason.