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. Dumping the dom in Qt Script
Forum Updated to NodeBB v4.3 + New Features

Dumping the dom in Qt Script

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 825 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
    jsprenkle
    wrote on last edited by
    #1

    Good afternoon,
    I've connected the Qt (4.8) script engine up within my application.
    I'm still learning how to make my application accessible from scripts.
    I'd like to debug it by enumerating everything the script engine can see.
    Has anyone else already developed this?

    The documentation says this should work, but it doesn't:
    @var _children = findChildren();
    for (var i = 0; i < _children.length; ++i)
    serialize( _children[i], indentation + ' ' );
    @

    Here's what I have so far:
    @var toType = function(obj) {
    return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
    }
    // recursively display object structure
    function serialize(node, indentation) {
    var out = indentation + '<' + node + ' type="' + toType(node) + '"' + '>';
    if ( toType(node) == 'object' )
    {
    for ( var prop in node ) {
    out += '\n' + serialize( prop, indentation + ' ' );
    }
    out += '\n' + indentation + '</' + node + '>' + '\n';
    }
    else
    out += node.toString() + '</' + node + '>';
    return out;
    }

    serialize( Game, '' );
    @

    I do get a dump:
    @
    <ClientOgreController(name = "Game") type="object">
    <CameraMan type="string">CameraMan</CameraMan>
    <HudAnimationFinished() type="string">HudAnimationFinished()</HudAnimationFinished()>
    <SkeletonDebug() type="string">SkeletonDebug()</SkeletonDebug()>
    <update() type="string">update()</update()>
    <CameraBookmark() type="string">CameraBookmark()</CameraBookmark()>
    <CameraUp() type="string">CameraUp()</CameraUp()>
    <CameraDown() type="string">CameraDown()</CameraDown()>
    <CameraToTerrain() type="string">CameraToTerrain()</CameraToTerrain()>
    <CameraForward() type="string">CameraForward()</CameraForward()>
    <ScreenCapture() type="string">ScreenCapture()</ScreenCapture()>
    <PhysicsDebug() type="string">PhysicsDebug()</PhysicsDebug()>
    <CameraOrbit() type="string">CameraOrbit()</CameraOrbit()>
    <Execute(const char*) type="string">Execute(const char*)</Execute(const char*)>
    <DebugConsoleTextEntered(QString) type="string">DebugConsoleTextEntered(QString)</DebugConsoleTextEntered(QString)>
    <DebugConsole() type="string">DebugConsole()</DebugConsole()>
    </ClientOgreController(name = "Game")>
    @

    There are some problems with it though:

    • Child objects and slots are reported as strings (See "CameraMan" and "SkeletonDebug()" )
    • Should I be exposing child objects as references or pointers?
      Q_PROPERTY( Mover* CameraMan READ getCameraMan )

    Thanks

    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