Important: Please read the Qt Code of Conduct -

How to connect QPushButton to a group of QPushButton with signal/slot

  • Hi,

    I have 9 QPushButton corresponding to the 9 digits 1-9, and I have a board of QPushButton (without text), I would like to connect with signal/slot the 9 digits buttons to my board in order to write the digits on the board's buttons.

    So first I created a "normal" project without UI, I placed my buttons and used a QSignalMap to do that and it worked.
    But now I would like to do that using the UI but I don't succeed or I could connect all of my 9 digits to all of my board's buttons so would be 9 times 81 (=729) connections which is not sensible, so how can we do something like QSignalMapper with the designer?


  • Why don't you just use the previous non-Ui solution withQSignalMapper pasting slightly modificated singnal mapping code after you call ui->setupUi(this)? Then you will have access to all these buttons and if you bundle your QPushButtons in one QButtonGroup (you can do it from QDesigner - select all buttons, right click and choose something like bundle to a new group - not sure if thats exactly that couse i have designer in my home language but i think you will get it) you can eaisly loop through them to map your signals.

  • @michelson

    Hi, thanks,
    Yes I can write a QSignalMapper but I wanted to try that with QtDesigner.
    Actually I would like to write a digit on the board's buttons but only the selected ones.
    So I will try to group the buttons as you said.

Log in to reply