[SOLVED] QScrollBar arrow keeps sending signals
Opening a QMessageBox in the QScrollBar valueChanged slot:
and then clicking one of the scroll bar arrows, causes the slot to be called repeatedly, but it is possible to exit the loop after a few iterations by holding the escape key down. The same occurs if opening a message box in the actionTriggered slot. This problem happens on Windows 7 with Qt 4.6.2 - is it a bug and is there any way around it?
Did you try with an up-to-date Qt? Qt4 is at 4.8.3 now!
EDIT: Might it be possible that QScrollBar::valueChanged() gets re-emitted when the About dialog closes and your Dialog gets focus again? If so, with your code you would end up in an infinite loop...
We are using 4.6.2 at work, so updating ito a newer version is not an option right now.
It seems that when a QDialog is opened in a slot connected to a QScrollBar signal caused by pressing one of the arrow keys, the scroll bar arrow button will never receive a releae event. I found a workaround by manually sending an event to the scroll bar:
@void CDialog::on_ScrollBar_valueChanged(int Value)
QMouseEvent Event(QEvent::MouseButtonRelease, QPoint(), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
QTimer::singleShot(0, this, SLOT(showAboutDialog()));
So the Dialog gets shown after the Slot has exited, making the workaround superfluous (hopefully).
Unfortunately it doesn't work -valueChanged() still gets called repeatedly and spawns dialogs.