Results 1 to 8 of 8

Thread: QSpinbox Button Access

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Location
    Austria
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QSpinbox Button Access

    Hi,

    I know this has been discussed several times here but I could not find any hint how to solve it actually. I would like to catch the mousepress event of a spin box in order to be able to reconfigure the box settings before the value actually changes. Background: my spinbox can support different ranges with different step sizes. So if one presses e.g. the up button I have to check before the actual value change whether a new range is to be entered or not (a new range would mean a new step size). For this reason I need to know whether up or down was pressed. Looking into the Qt code I can see that this decision is handled via internal hover states.

    Is there any way to either get access to this hover state or to find out about the currently pressed button ?

    Any hint appreciated.

    cheers

    m.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSpinbox Button Access

    I would like to catch the mousepress event of a spin box in order to be able to reconfigure the box settings before the value actually changes.
    You can either subclass, or use an event filter.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2011
    Location
    Austria
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSpinbox Button Access

    Well, that doesn't solve my problem. Of course I can subclass and catch the event but I don't know which button was pressed. I don't see a way to find out whether up or down button was pressed!

    m.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSpinbox Button Access

    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Feb 2011
    Location
    Austria
    Posts
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSpinbox Button Access

    :-) I guess there's still some misunderstanding ... I need access to the up/down buttons of the spinbox. I have subclassed QSpinbox already but I have no way to identify whether up or down was pressed when in mousepressevent !

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QSpinbox Button Access

    you can tell by the value.
    If the incoming value is larger than it was the up arrow, otherwise the down.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Can I get button Event on QSpinBox
    By sosanjay in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2010, 09:27
  2. Replies: 6
    Last Post: 22nd September 2008, 11:53
  3. Hardware button access in qtopia
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th August 2008, 22:16
  4. QSpinbox up and down button notification
    By seldeepchan in forum Qt Programming
    Replies: 1
    Last Post: 6th March 2008, 10:28
  5. QSpinBox button size
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 08:20

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
  •  
Qt is a trademark of The Qt Company.