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

  • 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;

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

  • Normaly we would do something like this,


    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.

  • 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.

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.