Results 1 to 8 of 8

Thread: Remove QSpinbox up/down arrows

  1. #1
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Remove QSpinbox up/down arrows

    I would like to remove the up/down arrows in a spinbox. I develop for Qt 4.2.0, and did not find a simple way to remove the up/down arrows. How do I solve it? And one more thing, is it possible to remove the cursor to?

    ...and no, I am not able to use QAbstractSpinBox::NoButtons (added for Qt 4.2.2). The company I work for has a commercial licens for 4.2.0 so I can't just download the latest version.

    Cheers!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Remove QSpinbox up/down arrows

    Why don't you use QLineEdit with a QIntValidator instead? You can probably also subclass the spin box and reimplement its paintevent to make sure no arrows are drawn.

    Are you sure the company can't download 4.2.2? The licence is not tied to a concrete version of Qt...

  3. #3
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Remove QSpinbox up/down arrows

    Why don't you use QLineEdit with a QIntValidator instead? You can probably also subclass the spin box and reimplement its paintevent to make sure no arrows are drawn.
    Subclassing the spinbox and reimplement the paintevent sounds like a good solution.

    Are you sure the company can't download 4.2.2? The licence is not tied to a concrete version of Qt...
    It's not tied to a version? I have got the impression from my superiors that it is? I'll see if I can get some clarification in the matter.

    Thanks for your answer wysota!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Remove QSpinbox up/down arrows

    Quote Originally Posted by SailinShoes View Post
    It's not tied to a version?
    No, it's not. It's only tied to a time period, as far as I know.

  5. #5
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Remove QSpinbox up/down arrows

    Perhaps their license expired at 4.2.0 and they haven't renewed it.

  6. #6
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Remove QSpinbox up/down arrows

    I followed wysota:s advice to reimplement the spinbox paintevent to make sure no arrows are drawn.

    But the cursor is still present? How can I get rid of it?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Remove QSpinbox up/down arrows

    You want to get rid of the cursor as well? Why not put a readonly line edit there then?

  8. #8
    Join Date
    Mar 2008
    Posts
    57
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Remove QSpinbox up/down arrows

    Simple...yet effective? It works...
    Thank you wysota.

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.