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. console functions
Forum Updated to NodeBB v4.3 + New Features

console functions

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 4 Posters 1.0k Views 2 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
    #1

    I've seen that console.log doesn't work in a JavaScript session in Qt. console.info does work, is there something like console.dir ?

    console.dir is useful because when used with objects it will expand and display the objects and sub objects with members and values.

    Kind Regards,
    Sy

    ODБOïO 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I've seen that console.log doesn't work in a JavaScript session in Qt. console.info does work, is there something like console.dir ?

      console.dir is useful because when used with objects it will expand and display the objects and sub objects with members and values.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi
      @SPlatten said in console functions:

      I've seen that console.log doesn't work in a JavaScript session in Qt

      what do you mean by "JavaScript session" ?

      https://doc.qt.io/qt-5/qtquick-debugging.html

      1 Reply Last reply
      0
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        I've got my C++ Qt Application signals connected to slots in JavaScript.

        Kind Regards,
        Sy

        ODБOïO 1 Reply Last reply
        0
        • SPlattenS SPlatten

          I've got my C++ Qt Application signals connected to slots in JavaScript.

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @SPlatten sorry i have no experience with that then
          do you mean instead of using QObject::connect() you are connecting a signal to a slot by using some js code?

          1 Reply Last reply
          0
          • SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            No I'm using QObject::connect:

            cnSignal = QObject::connect(this
                                       ,&clsQtTextEdit::jsonTextChanged
                                       ,[pobjScriptEng, strCall, strFile, strScript](QJsonObject objJSON) {
                                            QString strJSON = clsXMLnode::strJSON(objJSON)
                                                   ,strScriptWithCall = static_cast<QString>(strScript)
                                                                      + static_cast<QString>(strCall)
                                                                      + static_cast<QString>("(" + strJSON + ");");
                                            pobjScriptEng->evaluate(strScriptWithCall);
                                        });
            

            Kind Regards,
            Sy

            ODБOïO 1 Reply Last reply
            0
            • SPlattenS SPlatten

              No I'm using QObject::connect:

              cnSignal = QObject::connect(this
                                         ,&clsQtTextEdit::jsonTextChanged
                                         ,[pobjScriptEng, strCall, strFile, strScript](QJsonObject objJSON) {
                                              QString strJSON = clsXMLnode::strJSON(objJSON)
                                                     ,strScriptWithCall = static_cast<QString>(strScript)
                                                                        + static_cast<QString>(strCall)
                                                                        + static_cast<QString>("(" + strJSON + ");");
                                              pobjScriptEng->evaluate(strScriptWithCall);
                                          });
              
              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #6

              @SPlatten i have definitely no experience with that but i see this method, maybe it can help ..

                  QJSEngine myEngine;
                  myEngine.installExtensions(QJSEngine::ConsoleExtension);
                  QJSValue fun = myEngine.evaluate("(function(a, b) {  console.log(  a + b ) ; })");
                  QJSValueList args;
                  args << 1 << 2;
                  QJSValue threeAgain = fun.call(args);
              
              1 Reply Last reply
              0
              • SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #7

                console.log isn't available when using the Qt JavaScript engine, that is the function I would have used instead of console.info if it was available.

                Kind Regards,
                Sy

                ODБOïO 1 Reply Last reply
                0
                • SPlattenS SPlatten

                  console.log isn't available when using the Qt JavaScript engine, that is the function I would have used instead of console.info if it was available.

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by ODБOï
                  #8

                  @SPlatten you can make it available by calling QJSEngine::installExtensions()

                  1 Reply Last reply
                  0
                  • SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #9

                    @LeLev said in console functions:

                    installExtensions

                    I already have this in my C++ engine:

                         clsScriptHelper::mspobjJSeng->installExtensions(QJSEngine::AllExtensions);
                    

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #10

                      As pointed out by @LeLev , the link:
                      installExtensions

                      Shows in the text that using:
                      QJSEngine::ConsoleExtension

                      Should give console.log, however I've passed:
                      QJSEngine::AllExtensions

                      And I do not get console.log, however console.info works.

                      Anyone ?

                      Kind Regards,
                      Sy

                      mrjjM 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        As pointed out by @LeLev , the link:
                        installExtensions

                        Shows in the text that using:
                        QJSEngine::ConsoleExtension

                        Should give console.log, however I've passed:
                        QJSEngine::AllExtensions

                        And I do not get console.log, however console.info works.

                        Anyone ?

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Hi
                        The docs talks about
                        CONFIG+=qml_debug
                        in .pro file.
                        Im not sure if its related to that.

                        1 Reply Last reply
                        2
                        • SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #12

                          @mrjj, thank you, added that to pro file console.log now works. console.dir still doesn't.

                          Kind Regards,
                          Sy

                          mrjjM 1 Reply Last reply
                          0
                          • SPlattenS SPlatten

                            @mrjj, thank you, added that to pro file console.log now works. console.dir still doesn't.

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @SPlatten said in console functions:

                            console.dir

                            Are you sure this is included?
                            I have not seen it mentioned in the docs.

                            1 Reply Last reply
                            1
                            • SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by
                              #14

                              @mrjj , sorry I just assume that since console.log, console.info are part of the functions that are available in JavaScript when using Node.js that console.dir would also be present.

                              Kind Regards,
                              Sy

                              mrjjM B 2 Replies Last reply
                              0
                              • SPlattenS SPlatten

                                @mrjj , sorry I just assume that since console.log, console.info are part of the functions that are available in JavaScript when using Node.js that console.dir would also be present.

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @SPlatten
                                Hi
                                Its a valid assumption but i cant find any reference to it- so it seems not included.

                                1 Reply Last reply
                                3
                                • SPlattenS SPlatten

                                  @mrjj , sorry I just assume that since console.log, console.info are part of the functions that are available in JavaScript when using Node.js that console.dir would also be present.

                                  B Offline
                                  B Offline
                                  Bonnie
                                  wrote on last edited by
                                  #16

                                  @SPlatten
                                  No, it is not.
                                  You can check the available Console API.

                                  1 Reply Last reply
                                  2

                                  • Login

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