Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18954

Bug in MainWindow::backgroundButtonGroupClicked in Diagram Scene example

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.8.0
    • 4.7.0
    • Examples and Demos
    • None
    • 586258bfb520452860d8ff94c2db132d6ffd9e42

      In mainwindow.cpp in the Diagram Scene example, the method backgroundButtonGroupClicked(QAbstractButton *button) contains this code:

      mainwindow.cpp
      //! [1]
      void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
      {
          QList<QAbstractButton *> buttons = backgroundButtonGroup->buttons();
          foreach (QAbstractButton *myButton, buttons) {
          if (myButton != button)
              button->setChecked(false);
          }
      

      It seems that this snippet tries to uncheck all other buttons in the group, except the one just clicked. However setChecked(false) is called repeatedly on button, which is the button that the user just clicked and which is precisely the one that should remain checked.

      The correct method call is myButton->setChecked(false);.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            boddie David Boddie (Inactive)
            naproxeno Álvaro Manuel Recio Pérez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes