[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?



  • 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);
    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).



  • Unfortunately it doesn't work -valueChanged() still gets called repeatedly and spawns dialogs.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.