Results 1 to 11 of 11

Thread: catch signal stepDown from doubleSpinBox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    849
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6
    Thanked 163 Times in 151 Posts

    Default Re: catch signal stepDown from doubleSpinBox

    That should not be the case. Can you show us you .pro file, and the complete header file?

  2. #2
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: catch signal stepDown from doubleSpinBox

    Now I tried to subclass from doubleSpinBox again. It works now (new project, dont know why it failed in the old one).

    However the slot:
    void QScienceSpinBox::stepDown()

    is never called if I press up or down arrows.

    The code is looking like this:
    Qt Code:
    1. class QScienceSpinBox : public QDoubleSpinBox
    2. {
    3. Q_OBJECT
    4. public:
    5. QScienceSpinBox(QWidget * parent = 0);
    6.  
    7. QString textFromValue ( double value ) const;
    8. double valueFromText ( const QString & text ) const;
    9. ...
    10. private slots:
    11. void stepDown();
    12. void stepUp();
    13.  
    14. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Nov 2008
    Posts
    142
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 20 Times in 20 Posts

    Default Re: catch signal stepDown from doubleSpinBox

    Is it only the stepDown slot? The stepUp/Down slots are public in QDoubleSpinBox, and you are redeclaring them as private. Maybe that's causing your problem.

  4. #4
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: catch signal stepDown from doubleSpinBox

    Quote Originally Posted by rexi View Post
    Is it only the stepDown slot? The stepUp/Down slots are public in QDoubleSpinBox, and you are redeclaring them as private. Maybe that's causing your problem.
    makeing the slots public changes nothing. The functions are still not called at button up or down.

    EDIT:
    If I use the correct virtual function it works:
    Qt Code:
    1. // overwritten virtual function of QAbstractSpinBox
    2. void QScienceSpinBox::stepBy(int steps)
    3. {
    4. if (steps < 0)
    5. stepDown();
    6. else
    7. stepUp();
    8. }
    9.  
    10. void QScienceSpinBox::stepDown()
    11. {
    12. QSBDEBUG() << "stepDown()";
    13. setValue(value()/10.0);
    14. }
    15.  
    16. void QScienceSpinBox::stepUp()
    17. {
    18. QSBDEBUG() << "stepUp()";
    19. setValue(value()*10.0);
    20. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by pospiech; 3rd January 2009 at 14:55.

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.