Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox signal and slot connection problems
Qt 6.11 is out! See what's new in the release blog

QComboBox signal and slot connection problems

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yosei
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #3

      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);

      1 Reply Last reply
      4
      • Y Yosei

        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?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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);
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #3

          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);

          1 Reply Last reply
          4

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved