Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    SOLVED: use a created vector as range for QDoubleSpinBox and QSlider

    QML and Qt Quick
    2
    5
    2037
    Loading More Posts
    • 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.
    • 3
      32sthide last edited by

      I've created a vector v with 128 elements from -3000 to 3000 and I want to associate it to a QDoubleSpinBox and a QSlider, because dividing 6000 to 128 and setting the QDoubleSpinBox we have always the round problem. So can we set the range and the stepsize both to a QDoubleSpinBox and QSlider with a vector like this?

      @ std::vector<double> v(128);

      for (int i = 0; i < 128; ++i)
      {
      v[i] = -3000.0 + 6000.0 * (i) / 127.0;
      }@

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        Sorry, but I have no idea what you are trying to do here.

        1 Reply Last reply Reply Quote 0
        • 3
          32sthide last edited by

          Normaly we would do something like this,

          @doubleSpinBox->setDecimals(0);
          doubleSpinBox->setMinimum(min);
          doubleSpinBox->setMaximum(max);
          doubleSpinBox->setSingleStep(1.0);@

          I want the range to be the vector I created instead of choosing the min and max.

          So I want the SpinBox to be only allowed to be on the value from the vector I created.

          1 Reply Last reply Reply Quote 0
          • A
            andre last edited by

            Ah, so you want to control to only allow a discrete set of values. Right.

            No, the default Qt controls don't support that for the general case.

            1 Reply Last reply Reply Quote 0
            • 3
              32sthide last edited by

              Is there a different slider or widget that can support it or a way to go around that?

              1 Reply Last reply Reply Quote 0
              • First post
                Last post