Results 1 to 6 of 6

Thread: Can I get button Event on QSpinBox

  1. #1
    Join Date
    Jul 2009
    Posts
    36
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Can I get button Event on QSpinBox

    Hi All,

    I want to use button event instead of value changed Signal.
    Is there any way that I get button event Signal of QSpinBox.

    connect(ui->inputSpinBox, SIGNAL(valueChanged (int)), this, SLOT(SelectDisplay()));

    Can anyone tell me How to Implement Mouse Click event if there is no button event.
    Last edited by sosanjay; 7th January 2010 at 10:04.

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

    Default Re: Can I get button Event on QSpinBox

    You can install and event Filter on your spin box and trap any event you want there.
    http://doc.trolltech.com/4.5/qobject...allEventFilter
    ==========================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
    Jul 2009
    Posts
    36
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Can I get button Event on QSpinBox

    But In SpinBox there are two Buttons One for Increment and another is for decrement. So How can I distinguish between them.

    I want to write different function on Increment and decrement.

    Plz help me out for this problem.

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

    Default Re: Can I get button Event on QSpinBox

    Well, one way would be to look in the QSpinBox code.

    The other one, you could see if the current value is higher or lower then the last value, thus knowing which button was clicked.

    BTW - why is it that you don't use the valueChanged() signal?
    This is quite odd, and points probably to either potentially bad design.
    If you explain what it is you are trying to solve, we might help you with a better solution.
    ==========================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
    Sep 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Unhappy Re: Can I get button Event on QSpinBox

    I find myself wanting to do the same thing. Here's why:
    I want to make an edit field that has multiple sub-fields. A good example of something like what I'm trying to do is QDateEdit. Unfortunately, QDateEdit is much more complicated than I need. (I only need to do numeric entry separated by formatters, like 00-00-00-00.00) It also inherits from private interfaces, meaning it does things I can't. For my purposes, using the inputMask feature of QLineEdit seems like it would make the most sense. However, if I do that, then I lose the up-down arrows from QSpinBox. So, what it seems like would work is if I could connect the up-down arrows from a QSpinBox to my QLineEdit subclass... But, that doesn't seem to work either as this thread points out.
    In short, inheriting from either QSpinBox or QLineEdit leaves me wishing I had some functionality from the other class. Its a bit of a pickle. Any suggestions?

  6. #6
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default Re: Can I get button Event on QSpinBox

    maybe you need to create a customer widget for it

Similar Threads

  1. mouseMoveEvent(QMouseEvent* event), event->button()
    By faraslacks in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2008, 06:22
  2. Replies: 6
    Last Post: 22nd September 2008, 12:53
  3. QSpinbox up and down button notification
    By seldeepchan in forum Qt Programming
    Replies: 1
    Last Post: 6th March 2008, 11:28
  4. QSpinBox button size
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 13th August 2007, 09:20
  5. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 06:03

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.