[SOLVED] QScrollBar arrow keeps sending signals
-
Hi,
Opening a QMessageBox in the QScrollBar valueChanged slot:
@void CDialog::on_horizontalScrollBar_valueChanged()
{
QMessageBox::aboutQt(this);
}
@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?
-
-
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);
QApplication::sendEvent(m_ui.ScrollBar, &Event);
}@ -
Maybe:
@void CDialog::on_horizontalScrollBar_valueChanged(void)
{
QTimer::singleShot(0, this, SLOT(showAboutDialog()));
}void CDialog::showAboutDialog(void)
{
QMessageBox::aboutQt(this);
}@So the Dialog gets shown after the Slot has exited, making the workaround superfluous (hopefully).