Results 1 to 3 of 3

Thread: How to Set Range in qspinbox and add exception value?

  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default 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
    Qt Code:
    1. QSpinBox *spinBox = new QSpinBox(parent);
    2. spinBox->setRange(1024, 65535);
    To copy to clipboard, switch view to plain text mode 
    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?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  3. The following user says thank you to Ginsengelf for this useful post:

    npatil15 (17th April 2019)

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    npatil15 (17th April 2019)

Similar Threads

  1. range widget?
    By TorAn in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2016, 09:01
  2. QwtSlider with zero range
    By Induriel in forum Qwt
    Replies: 6
    Last Post: 29th October 2015, 19:44
  3. Out of range detection
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2009, 10:32
  4. Index out of Range
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2008, 16:33
  5. QLineEdit set min max range?
    By whitefurrows in forum Qt Programming
    Replies: 29
    Last Post: 11th June 2006, 00:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.