When I Scroll a widget in QScrollArea, its scrollbar's step is not singleStep() but singleStep() * 3.
I set singleStep of QScrollArea's verticalScrollBar() to 30 in order to scroll 30 per scroll, but it scrolls 90 per scroll.
MyScrollArea::MyScrollArea(QWidget* parent) : QScrollArea(parent) {
this->verticalScrollBar()->setSingleStep(30); // set singleStep to 30
connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(on_valuechange(int)));
}
MyScrollArea::on_valuechange(int i) {
qDebug() << i; // always 90n, not 30n
}
or is this just the problem with my mouse?
As mentioned in the comments, your single step is being multiplied by the system's number of lines.
If you want to have the same scrolling step regarding less system's settings you always adjust the step accordingly. For example, for Windows:
#include <winuser.h>
#include <QScrollBar>
void setSingleStep(QScrollBar* bar, int step) {
UINT sys_steps;
SystemParametersInfoA(SPI_GETWHEELSCROLLLINES, 0, &sys_steps, 0);
bar->setSingleStep(step / sys_steps);
}