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

Boolean in Qt Script

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 7.7k 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Hellow, how can i add boolean to script engine, i try:
    @bool isDegrees;
    QScriptValue scriptIsDegrees = scriptEngine.newObject(&isDegrees);@
    But i get this error:

    bq. Error 1 error C2664: QScriptValue QScriptEngine:: newObject (QScriptClass *, const QScriptValue &): can not convert parameter 1 from 'bool *' in 'QScriptClass *' c: \ Users \ ruzik \ Documents \ Visual Studio 2008 \ Projects \ RizekMath \ RizekMath \ Widges \ RCalculatorWidget \ RCalculatorWidget.cpp 37

    In advance thank you for your help!

    [edit : fixed formatting, Eddy]

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Take another look at the "QScriptEngine::newObject()":http://doc.qt.nokia.com/4.7/qscriptengine.html#newObject-2 signature.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        I dont find any information to solve problem, but i find way how can i do it:
        @ QScriptValue scriptIsDegrees(&scriptEngine,false);
        scriptEngine.globalObject().setProperty("isDegrees", scriptIsDegrees);@
        But why was my first way wrong?
        Please explain me more

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          bq. QScriptValue QScriptEngine:: newObject (QScriptClass *, const QScriptValue &): can not convert parameter 1 from ‘bool *’ in ‘QScriptClass *

          Meaning :
          There is no function in the QScriptEngine class which takes as it's first parameter a pointer to a boolean. The compiler tries to convert it to one of the existing signatures, but doesn't succeed.

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ruzik
            wrote on last edited by
            #5

            I undrestund it, i cant understund how can i do right

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Ruzik
              wrote on last edited by
              #6

              I need to add bool value to script

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                Hu Ruzik,

                your first post had the bug, that you used a function, that wanted a QScriptClass pointer as first parameter:

                @
                QScriptEngine::newObject ( QScriptClass * scriptClass, const QScriptValue & data = QScriptValue() )
                @

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Ruzik
                  wrote on last edited by
                  #8

                  Why when i write this:
                  @QScriptValue scriptIsDegrees(&scriptEngine,isDegrees);@
                  It is all right, but i dont find this constructor in assist

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on last edited by
                    #9

                    Perhaps this constructor is not documented, but in the header file, it exists:

                    @
                    QScriptValue();
                    ~QScriptValue();
                    QScriptValue(const QScriptValue &other);
                    QScriptValue(QScriptEngine *engine, SpecialValue val);
                    QScriptValue(QScriptEngine *engine, bool val);
                    QScriptValue(QScriptEngine *engine, int val);
                    QScriptValue(QScriptEngine *engine, uint val);
                    QScriptValue(QScriptEngine *engine, qsreal val);
                    QScriptValue(QScriptEngine *engine, const QString &val);
                    @

                    EDIT: I looked at the docs, these constructors are obsolete...

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Ruzik
                      wrote on last edited by
                      #10

                      If i do it:
                      @QScriptValue(QScriptEngine *engine, bool val);@
                      I am add in script only variable not value, how can i add value

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Ruzik
                        wrote on last edited by
                        #11

                        I need to do something like this
                        @QScriptValue(QScriptEngine *engine, &bool val);@

                        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