Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. SOLVED: use a created vector as range for QDoubleSpinBox and QSlider

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

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 2.2k Views
  • 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 Offline
    3 Offline
    32sthide
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • 3 Offline
        3 Offline
        32sthide
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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
          0
          • 3 Offline
            3 Offline
            32sthide
            wrote on last edited by
            #5

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

            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