Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QComboBox signal and slot connection problems



  • I am developing an application for testing students and I have a problem connecting a signal from a QComboBox to my slot. I tried to use the new connect-function syntax but nothing works:

    connect(gradeBox, &QComboBox::activated(QString), this, &HomeWindow::printGrade(QString));
    

    this causes a lot of errors, homewindow.cpp line 60 is line with "connect":
    a070d1ec-f096-46fa-8675-6977a53d2a48-image.png
    I tried to use various options for recording a parameter in a signal and slot as "const QString" , "QString&" or "const QString&" but this isn't working anyway. I readed Qt Documentation but don't find answer. What am I doing wrong?


  • Lifetime Qt Champion

    Hi
    Its due to it being overloaded so there is an INT version and STRING version

    try
    connect(comboBox, QOverload<QString>::of(&QComboBox::activated), this, &HomeWindow::printGrade);


  • Qt Champions 2019

    @Yosei said in QComboBox signal and slot connection problems:

    connect(gradeBox, &QComboBox::activated(QString), this, &HomeWindow::printGrade(QString));

     connect(gradeBox, &QComboBox::activated, this, &HomeWindow::printGrade);
    

  • Lifetime Qt Champion

    Hi
    Its due to it being overloaded so there is an INT version and STRING version

    try
    connect(comboBox, QOverload<QString>::of(&QComboBox::activated), this, &HomeWindow::printGrade);


Log in to reply