Skip to content
  • 0 Votes
    2 Posts


    It seems the solution was to use;

    Earlier in the code to register JSValue as a meta Type.
    I had already tried this, but was missing the string "JSValue" from the call.
    So it seems that both the type and the string are required.

    All good working now,
    Hopefully it will all work in 6.5 too, as it seems Qt has removed the string variant from the SDK.

  • 0 Votes
    13 Posts

    @JKSH Not applicable because I have other event sink classes.
    Also, I use the SLOT string because (for the sake of keeping this post clear, I didn't demonstrate that) I have file-open scenarios too: void OnSingleSelect(const QString &file) and void OnMultiSelect(const QStringList &files). They don't share signatures, so either I need to template-ize (which doesn't work well w/ signals&slots), or to repeat and tweak the helper function.
    Wait: will selectedFilter trigger setDefaultSuffix along with selectNameFilter? Didn't find evidence in the source tree.
    Also again: Linux Qt 5.6.1, selectedFilter doesn't setDefaultSuffix. Call chain according to :
    QFileDialog::getSaveFileName -> QFileDialog::getSaveFileUrl -> QFileDialog::selectNameFilter -> QFileDialogPrivate::_q_useNameFilter, which doesn't seem to be doing the work (at least, in my case) after the user clicked OK.

  • 0 Votes
    1 Posts
    No one has replied
  • 0 Votes
    8 Posts

    @Dariusz If you check the PySide documentation you will see that there is no overload taking a lambda or any function/method. There are only overloads accepting strings containing method name. So, it seems not possible with PySide.
    But instead of using QApplication instance you could create your own class with methods you want to call using invokeMethod.

  • 0 Votes
    4 Posts

    Thanks @raven-worx and @Chris-Kawa for the quick answers.

    @raven-worx said in Qt5 & invokeMethod:

    the 2 methods behave the same.

    I know that they seem to behave in the same way.
    But creating an timer object, running & processing the timer/timeout and deleteing the object afterwards, feels like it should be more work than queing a function call via Q_Object-Macro-Magic. However the compiler may break it down to the same thing, after all.

    @raven-worx said in Qt5 & invokeMethod:

    You can check the return value of invokeMethod() and add an assertion.

    That is actually a good idea, that way one would always get an immediate notification when the call becomes invalid due to changes made.
    Still inconvenient, but much less so.

    @Chris-Kawa said in Qt5 & invokeMethod:

    In Qt 5.10 (currently in alpha) there's gonna be an overload taking pointer to function, so you'll be able to do:

    YES, thanks for the info, I was not aware of that change.

    Now I'm hyped for Qt 5.10 more so than previously!

    With that said, I would consider my question answered.
    Thanks everyone.

  • 0 Votes
    6 Posts

    OH Thx a lot that was it. Without the const, it works.
    So my code went from

    void AnotherClass::showInfo(MyClass const *item) { // Same stuff as above (2nd post) }


    void AnotherClass::showInfo(MyClass *item) { // Same stuff as above (2nd post) }
  • 0 Votes
    8 Posts

    @SGaist said in Crashing when using QJSValue call:

    Did you check whether your application has a leak ?

    Yes, i have tested it for leaks. Does not seem to be the case.

    Is to be used externally?