[Development] QSpinBox 1 up/down click changes value by 2 steps

Lorenz Haas lykurg at gmail.com
Tue Jul 23 07:25:30 CEST 2013


Hi,

for me it all looks like a bug. Have you filed a bug repost
(bugreports.qt-project.org)?

Funny part is when you donwstip it to minimal

#include <QApplication>
#include <QSpinBox>

#include <unistd.h>

class SomeObject : public QObject {
    Q_OBJECT

public Q_SLOTS:
    void someSlot(int)
    {
        sleep(1); // Simulate a model that as bit of work to do to
update itself
    }
};

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QSpinBox spinBox;
    spinBox.setValue(35);
    spinBox.show();

    SomeObject o;
    QObject::connect(&spinBox, SIGNAL(valueChanged(int)),
                     &o, SLOT(someSlot(int)));

    return app.exec();
}

#include "main.moc"


the fist click works like expected, all following in/decreases the value
by two.

Best,
Lorenz

Am 22.07.2013 19:35, schrieb Carl Schumann:
> Hi,
> 
> I am having some problem with my use of Qt's QSpinBox.   In my
> application QSpinBox 1 up/down click changes the boxes value by 2
> steps.  (There are two separate valueChanged signals each by one
> step.)    The issue appears to be related to the amount of time taken by
> a slot attached to the valueChanged signal.     I have attached the
> small amount of source code needed to reproduce the issue, which is
> based on an example in the Qt 4 2nd Edition textbook.   I am
> experiencing this bug with Qt 4.8.4.  I don't have access to Qt 5
> because of incompatibilities with our Linux distribution.   I did try it
> on Qt 4.5.0 and got 3 steps for each click.
> 
> I am not sure what expectations are put on slot code.   Are slots
> expected to meet time constraints?  If no, have I found a bug Qt?
> 
> Sincerely,
> Carl Schumann
> 
> 
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
> 




More information about the Development mailing list