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. Correcting data by equation parameters
Forum Updated to NodeBB v4.3 + New Features

Correcting data by equation parameters

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 4 Posters 5.5k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    What do you mean by "command line" ?

    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
    • E Offline
      E Offline
      erytcg
      wrote on last edited by
      #3

      Maybe QLineEdit it doesn't matter, widget to input String.

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

        Are you looking to implement something like SpeedCrunch ?

        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
        • E Offline
          E Offline
          erytcg
          wrote on last edited by
          #5

          I need something simple. Maybe only y=ax+b;

          mrjjM 1 Reply Last reply
          0
          • E erytcg

            I need something simple. Maybe only y=ax+b;

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

            @erytcg
            and you want to parse it and execute it ?
            There are many examples of a small calculator on the net. its a common
            text book task.

            1 Reply Last reply
            2
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #7

              https://en.wikipedia.org/wiki/Shunting-yard_algorithm

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              2
              • E Offline
                E Offline
                erytcg
                wrote on last edited by
                #8

                any example for calculating without buttons? only input line.

                mrjjM 1 Reply Last reply
                0
                • E erytcg

                  any example for calculating without buttons? only input line.

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

                  @erytcg
                  The link VRonin gave is without buttons.
                  Just the pure way to do it.

                  1 Reply Last reply
                  1
                  • E Offline
                    E Offline
                    erytcg
                    wrote on last edited by
                    #10

                    It is possible to use varibales names in this?

                    mrjjM 1 Reply Last reply
                    0
                    • E erytcg

                      It is possible to use varibales names in this?

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

                      @erytcg
                      yeah should be as you can just treat the variable as a number and substitute when you calculate the result.
                      it also support operator precedence but stuff like
                      x=(1.3x+1)^2;
                      will require somewhat a more data complex model to handle flawless i think.

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        erytcg
                        wrote on last edited by
                        #12

                        And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D

                        mrjjM 1 Reply Last reply
                        0
                        • E erytcg

                          And one more question this algorithm is fast? I have a looot of data and I have to calculate it in real time:D

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

                          @erytcg
                          well, it's minimal and makes handling the expressions easier (for the programmer) but since it is sort of a text parser, not that fast but for small expressions its not wildly time consuming.

                          1 Reply Last reply
                          0
                          • mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #14

                            Depending on what you need to handle, maybe using something like
                            https://github.com/ArashPartow/exprtk ?

                            1 Reply Last reply
                            0
                            • E Offline
                              E Offline
                              erytcg
                              wrote on last edited by erytcg
                              #15

                              Can I use QScriptEngine?

                              But I have problem

                              #include <QtScript/qscriptengine.h>
                              #include <QtScript/qscriptvalue.h>
                              
                              QString x = ui->correctDataLine->displayText();
                              QScriptEngine myEngine;
                              QScriptValue x2 = myEngine.evaluate(x);
                              qDebug() << x2.toNumber();
                              
                              undefined reference to `_imp___ZN13QScriptEngineC1Ev'
                              
                              mrjjM 1 Reply Last reply
                              0
                              • E erytcg

                                Can I use QScriptEngine?

                                But I have problem

                                #include <QtScript/qscriptengine.h>
                                #include <QtScript/qscriptvalue.h>
                                
                                QString x = ui->correctDataLine->displayText();
                                QScriptEngine myEngine;
                                QScriptValue x2 = myEngine.evaluate(x);
                                qDebug() << x2.toNumber();
                                
                                undefined reference to `_imp___ZN13QScriptEngineC1Ev'
                                
                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by mrjj
                                #16

                                @erytcg
                                do you have
                                QT += script
                                in the pro file?

                                1 Reply Last reply
                                3
                                • E Offline
                                  E Offline
                                  erytcg
                                  wrote on last edited by
                                  #17

                                  Ok thanks my bad:(
                                  Do you think can I use this with variables names?

                                  mrjjM 1 Reply Last reply
                                  1
                                  • E erytcg

                                    Ok thanks my bad:(
                                    Do you think can I use this with variables names?

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

                                    @erytcg
                                    What do you mean with "variables names" ?
                                    To put inside QScriptEngine or what you wanna do with variables?

                                    1 Reply Last reply
                                    0
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by mrjj
                                      #19

                                      Ah I see where you are aiming :)
                                      Yes you can use it for your use case. Depending on the complexity you need.
                                      http://www.informit.com/articles/article.aspx?p=1405559&seqNum=2
                                      Using script with js to play calculator.

                                      1 Reply Last reply
                                      0
                                      • E Offline
                                        E Offline
                                        erytcg
                                        wrote on last edited by
                                        #20

                                        I have this
                                        0_1509308181416_1a4c9133-55ab-43be-9958-7c649b4c8d49-obraz.png

                                        And I have variable name: x. I put to QLineEdit 1+x * 3
                                        And script automatically calculate new value of x.
                                        x = 1+x*3

                                        mrjjM 1 Reply Last reply
                                        0
                                        • E erytcg

                                          I have this
                                          0_1509308181416_1a4c9133-55ab-43be-9958-7c649b4c8d49-obraz.png

                                          And I have variable name: x. I put to QLineEdit 1+x * 3
                                          And script automatically calculate new value of x.
                                          x = 1+x*3

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

                                          @erytcg
                                          Only if you program in js to solve it. it can evaluate values for you but
                                          it cant tell you what x is as far as i know.

                                          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