Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] QScrollBar arrow keeps sending signals

    General and Desktop
    2
    5
    2120
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Q
      qcoder last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • M
        MuldeR last edited by

        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...

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply Reply Quote 0
        • Q
          qcoder last edited by

          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);
          }@

          1 Reply Last reply Reply Quote 0
          • M
            MuldeR last edited by

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

            My OpenSource software at: http://muldersoft.com/

            Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

            Go visit the coop: http://youtu.be/Jay...

            1 Reply Last reply Reply Quote 0
            • Q
              qcoder last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post