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. QtSlider exmaple in javascript ?
Forum Updated to NodeBB v4.3 + New Features

QtSlider exmaple in javascript ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.8k 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.
  • L Offline
    L Offline
    Largol
    wrote on last edited by
    #1

    Hi everyone,
    as I'm writing code in Javascript and using QtCreator for the UI part, I didn't found an example regarding Sliders object in Javascript format.....

    Is there an example ?

    Best Regards.
    Largol.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Largol
      You have 2 ways to do:
      http://doc.qt.io/qt-5/qml-qtquick-controls-slider.html
      http://doc.qt.io/qt-5/qml-qtquick-controls2-slider.html

      157

      1 Reply Last reply
      2
      • L Offline
        L Offline
        Largol
        wrote on last edited by
        #3

        I don't see any example in the two links you provided.
        I have trouble with the connect function....

        Best Regards.
        Largol.

        raven-worxR 1 Reply Last reply
        0
        • L Largol

          I don't see any example in the two links you provided.
          I have trouble with the connect function....

          Best Regards.
          Largol.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Largol said in QtSlider exmaple in javascript ?:

          I have trouble with the connect function....

          in order to receive help you should also tell what your problem is

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • L Offline
            L Offline
            Largol
            wrote on last edited by
            #5

            Ok, let's go for it.

            I have this code
            function StepperMotorON()
            {
            // Motor on with a user defined value for current
            var current = "0";
            var result = "";
            UI_StepperMotorCurrentSlider.setRange(0,232);
            value = parseInt(int, 16);
            QObject.connect(StepperMotorCurrentSlider, SIGNAL(valueChanged(int),lineEditCurrentMotor, SLOT(setText(parseInt(int, 16)));
            // QObject.connect(StepperMotorCurrentSlider, SIGNAL(valueChanged(parseInt(int,var),lineEditCurrentMotor, SLOT(setText(var));
            current = UI_StepperMotorCurrentSlider.valueChanged(current);
            current = (current*1.074);
            current = current.toFixed(0);
            /*if(current > 150)
            {
            return -1;
            } */
            current = current.toString(16);
            //to debug
            UI_lineEditIofStepperMotor.setText(current);
            // confidential code to drive the motor.
            // if (result == "")
            // {
            return -1;
            }
            return 1;
            }

            raven-worxR 1 Reply Last reply
            0
            • L Largol

              Ok, let's go for it.

              I have this code
              function StepperMotorON()
              {
              // Motor on with a user defined value for current
              var current = "0";
              var result = "";
              UI_StepperMotorCurrentSlider.setRange(0,232);
              value = parseInt(int, 16);
              QObject.connect(StepperMotorCurrentSlider, SIGNAL(valueChanged(int),lineEditCurrentMotor, SLOT(setText(parseInt(int, 16)));
              // QObject.connect(StepperMotorCurrentSlider, SIGNAL(valueChanged(parseInt(int,var),lineEditCurrentMotor, SLOT(setText(var));
              current = UI_StepperMotorCurrentSlider.valueChanged(current);
              current = (current*1.074);
              current = current.toFixed(0);
              /*if(current > 150)
              {
              return -1;
              } */
              current = current.toString(16);
              //to debug
              UI_lineEditIofStepperMotor.setText(current);
              // confidential code to drive the motor.
              // if (result == "")
              // {
              return -1;
              }
              return 1;
              }

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @Largol said in QtSlider exmaple in javascript ?:

              QObject.connect(StepperMotorCurrentSlider, SIGNAL(valueChanged(int),lineEditCurrentMotor, SLOT(setText(parseInt(int, 16)));

              this syntax doesn't work in QML.
              In QML you use the Connections type

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1
              • L Offline
                L Offline
                Largol
                wrote on last edited by
                #7

                Well, i use "straight" javascript (as it was requested by previous owner of the code).

                So shall I mix QML with Javascript in this case ?

                Best Regards.
                Largol.

                raven-worxR 1 Reply Last reply
                0
                • L Largol

                  Well, i use "straight" javascript (as it was requested by previous owner of the code).

                  So shall I mix QML with Javascript in this case ?

                  Best Regards.
                  Largol.

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  @Largol
                  when you do not have the requirement for pure JS, then i would suggest that you use the benefits of QML.
                  Since you anway let your script run in a QML engine right?

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1

                  • Login

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