Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QScrollBar arrow keeps sending signals

[SOLVED] QScrollBar arrow keeps sending signals

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.4k Views
  • 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 Offline
    Q Offline
    qcoder
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      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
      0
      • Q Offline
        Q Offline
        qcoder
        wrote on last edited by
        #3

        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
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          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
          0
          • Q Offline
            Q Offline
            qcoder
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved