Skip to content
  • 0 Votes
    13 Posts
    4k Views
    Pl45m4P

    @Burke212

    One more thing... :)
    So you create 10 Buttons and connect them somehow to "numPressed", that prints or computes the button-number, if a button is clicked + released, right?

    The use of a QButtonGroup would make this even easier.
    https://doc.qt.io/qt-5.6/qbuttongroup.html

    Add your buttons to your buttonGroup and setID of each button.
    ButtonGroup also provides signals and functions to work with. Maybe your own connection is not necessary anymore and you dont need to rename every single button, because you can work with the groupID.

    When adding the buttons to your group, set your own IDs, as the default buttonID in a buttonGroup starts at -2 and decreases with every additional button (this gave me headache in one of my projects some time ago... Of course, I didnt set my own IDs and was expecting the ID to start at 0 increasing. And of course I didnt read the Docs of the addButton-Function back then) :)