Important: Please read the Qt Code of Conduct -

[SOLVED] assign button ID

  • hello,

    I need to assign some buttons an ID. I created my buttons in QtDesigner and it doesn't seem it is possible with QtDesigner to assign IDs (correct me if i am wrong).

    So i am doing this into the code.

    I am assigning an ID :

    ui->outputGroup->setId(ui->out1, 1);

    but when i grab this ID the application crashes :


    It seems i am doing it wrong

    qDebug() << "button pressed : " << ui->inputGroup->button(1) << endl;

    This always returns

    button pressed : QObject(0x0)

    whatever the button is : button(1), button(2), button(3) etc...

  • Lifetime Qt Champion


    Unless it's a typo here, you are assigning IDs to the outputGroup and request the button from the inputGroup

  • ok. The problem stands between the keyboard and the chair...
    thanks !

  • Lifetime Qt Champion

    Don't worry, it happens to all of us ;)

    Happy coding !

Log in to reply