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. QScript and visibility of QObjects
Forum Updated to NodeBB v4.3 + New Features

QScript and visibility of QObjects

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    I'm trying to understand why the following class give me this behavior: @ class ToolFactory : public QObject
    {
    Q_OBJECT
    public:
    Q_INVOKABLE Tool* newTool_broken(QString name);
    Q_INVOKABLE void newTool_working(QString name)
    {
    Tool* t = newTool_broken(name);
    t->setParent(this);
    t->setObjecName(name);
    }
    }@ Now from the QScript side,
    if I call Factory.newTool_broken("myName"), it fails saying @Factory.newTool_broken("myName");

    TypeError: cannot call newTool_broken(): unknown return type `Tool*' (register the type with qScriptRegisterMetaType())@ but if I call Factory.newTool_working("myName"), I can then use @Factory.myName
    Tool(0xa042378, name = "myName") @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      As stated in the error did you made Tool known to the Meta Object system using qScriptRegisterMetaType ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        No, and I don't want to do that because I can use my Tool* object using the "trick" in newTool_working() so the Meta Object seem to be aware of what a Tool* is.

        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