How to Set Range in qspinbox and add exception value?
Hi Everyone,
I'm working on TCP/UDP communication in which I have set a range for ports as below
Code:
spinBox->setRange(1024, 65535);
Now I want to connect to port 80(specific), but because of the above configuration, I'm unable to use port 80.
So my question is, does it possible to add exceptional value/port in spinbox?
Re: How to Set Range in qspinbox and add exception value?
Hi, I don't think that's possible. There are a bunch of other options, e.g. use a QComboBox for a bunch of pre-defined ports like your port 80, and the QSpinBox for custom ports >= 1024, and use two QRadiobuttons to switch between both.
Ginsengelf
Re: How to Set Range in qspinbox and add exception value?
If you have a set of special values then a QComboBox like suggested by Ginsengelf could also be extended to have one value for "range" and which enables/shows the spinbox when selected.
If you have one special value, you could use QSpinBox::setSpecialValueText().
It displays a custom text instead of the numerical value for the spinbox' minimum.
You could have possibly multiple special values at the beginning or the end by deriving from QSpinBox and overwrite textFromValue() such that the numbers are not displayed but a special text.
Cheers,
_