Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Advice on how to implement if possible?
Qt 6.11 is out! See what's new in the release blog

Advice on how to implement if possible?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 173 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I want to implement a function that is invokable from JavaScript, I want to be able to call C++ functions from JavaScript, all the controls have unique ID's.

    This is what I have so far:

    /**
     * @brief clsScriptHelper::invoke
     * @param crstrID Constant reference to ID for node / widget to invoke
     * @param crstrMethod Constant reference to method to invoke
     * @param crlstArgs Constant reference to stringlist containing arguments
     * @return true if invoke call ok else false
     */
    bool clsScriptHelper::invoke(const QString& crstrID, const QString& crstrMethod
                                      , const QStringList& crlstArgs) {
        clsXMLnode* pobjNode(clsXMLnode::spobjGetNodeById(crstrID));
        QWidget* pobjWidget;
        bool blnRC(false);
        if ( pobjNode != nullptr
        && (pobjWidget = pobjNode->pobjGetWidget()) != nullptr ) {
            QGenericArgument ga(crlstArgs[0].toLatin1().constData());
            blnRC = QMetaObject::invokeMethod(pobjWidget, crstrMethod.toLatin1(), ga);
        }
        return blnRC;
    }
    

    I'm looking for some input / help on how I could implement this? Ideally I would like to pass all the required arguments from crlstArgs.

    The above has no warnings, but presently its hard coded for just a single parameter, I would like it to adapt to the number of arguments passed in the list.

    Kind Regards,
    Sy

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved