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. Best way to expose a QObject to JavaScript without QWebFrame?
Forum Updated to NodeBB v4.3 + New Features

Best way to expose a QObject to JavaScript without QWebFrame?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    Hey there,

    I am interested in exposing a QObject in my program to JavaScript and I am wondering how to expose it.
    I saw the following code example on the QtWebKit Bridge doc page:
    @
    // ...
    QWebFrame *frame = myWebPage->mainFrame();
    frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);
    // ...
    @

    The problem with exposing the QObject this way is that it appears to require you to have a QWebView, something I'm not really eager to do in the part of my application I'm dealing with. Is there a way to expose my QObject to JavaScript without being constricted by having a QWebView in my application?

    Thanks!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on last edited by
      #2

      What exactly do you want to achieve?

      We have in one of our applications a JavaScript interface which uses QScriptEngine and the meta object system of Qt to access the objects. I am not sure if that is what you want to have.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on last edited by
        #3

        I would like to open up part of my application to a website I am building

        1 Reply Last reply
        0
        • B Offline
          B Offline
          butterface
          wrote on last edited by
          #4

          If your really dont want to use the WebFrame you might use json objects and read it again if a request comes in.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on last edited by
            #5

            how exactly would that work? Is it possible to have the web frame without having the web view?

            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