Important: Please read the Qt Code of Conduct -

[Solved]why several rationbutton cannot be connect to same slot?

  • I used QtDesigner created a interface which includes FD, TD50, TD33 , TD25 four radio buttons in a group. the code generated by UI is
    layoutWidget_3 = new QWidget(WaveFormGroupBox);
    layoutWidget_3->setGeometry(QRect(10, 31, 181, 62));
    WaveFormLayout = new QGridLayout(layoutWidget_3);
    WaveFormLayout->setContentsMargins(11, 11, 11, 11);
    WaveFormLayout->setContentsMargins(0, 0, 0, 0);
    FDradioButton = new QRadioButton(layoutWidget_3);

        WaveFormLayout->addWidget(FDradioButton, 0, 0, 1, 1);
        TD25radioButton = new QRadioButton(layoutWidget_3);
        WaveFormLayout->addWidget(TD25radioButton, 1, 0, 1, 1);
        TD33radioButton = new QRadioButton(layoutWidget_3);
        WaveFormLayout->addWidget(TD33radioButton, 1, 1, 1, 1);
        TD50radioButton = new QRadioButton(layoutWidget_3);
        WaveFormLayout->addWidget(TD50radioButton, 0, 1, 1, 1);


    then in the constructor of my class, I tried to connect these radio button to the same slot
    connect(ui->FDradioButton, SIGNAL(toggled()), this, SLOT(waveformToggled()));
    connect(ui->TD50radioButton, SIGNAL(clicked())), this, SLOT(waveformToggled());
    only connection for FDradionButton works, all the others give me compiling error:
    no matching function for call to remote::connect(QRadioButtons *&, const char *)'
    and the lists four candiates for the matching function.

    **found the problem, the "()" does not match correctly,
    @ connect(ui->TD50radioButton, SIGNAL(clicked())), this, SLOT(waveformToggled());@
    should be
    @ connect(ui->TD50radioButton, SIGNAL(clicked()), this, SLOT(waveformToggled()));@
    Qt editor does not highlight this kind of error. :(

  • As it looks you have solved your problem.
    If this is the case, thanks for posting your. However, please mark also the title with [Solved].

Log in to reply