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. A signal problem
Forum Updated to NodeBB v4.3 + New Features

A signal problem

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 734 Views 3 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.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1

    Hi,

    I have a QComboBox named cboBox, void itemChanged(int); slot and a connection like this:

    connect(cboBox, SIGNAL(currentItemChanged(int)), this, SLOT(itemChanged(int)));
    ...
    void DialogTest::itemChanged(int item)
    {
      ...
    }
    

    But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)

    CP71C 1 Reply Last reply
    0
    • Q qcoderpro

      Hi,

      I have a QComboBox named cboBox, void itemChanged(int); slot and a connection like this:

      connect(cboBox, SIGNAL(currentItemChanged(int)), this, SLOT(itemChanged(int)));
      ...
      void DialogTest::itemChanged(int item)
      {
        ...
      }
      

      But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)

      CP71C Offline
      CP71C Offline
      CP71
      wrote on last edited by
      #2

      @qcoderpro
      Hi,
      "But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)" means currentItemChanged isn't a signal.

      Maybe you want to write currentIndexChanged(int index).

      Q 1 Reply Last reply
      3
      • CP71C CP71

        @qcoderpro
        Hi,
        "But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)" means currentItemChanged isn't a signal.

        Maybe you want to write currentIndexChanged(int index).

        Q Offline
        Q Offline
        qcoderpro
        wrote on last edited by
        #3

        @CP71

        Thank you. And if I want to use the new style, I need lambda, right?
        I declared it this way but doesn't work:

        connect(cboBox, &QComboBox::currentIndexChanged, this, [this](int item) {
                itemChanged(item);
            });
        
        Pl45m4P 1 Reply Last reply
        0
        • Q qcoderpro

          @CP71

          Thank you. And if I want to use the new style, I need lambda, right?
          I declared it this way but doesn't work:

          connect(cboBox, &QComboBox::currentIndexChanged, this, [this](int item) {
                  itemChanged(item);
              });
          
          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @qcoderpro said in A signal problem:

          And if I want to use the new style, I need lambda, right?

          Lambdas are a different thing...
          You can achieve the same result by connecting your button to your slot like this:

          connect(cboBox, &QComboBox::currentIndexChanged, this, &DailogTest::itemChanged);
          

          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          Q 1 Reply Last reply
          1
          • Pl45m4P Pl45m4

            @qcoderpro said in A signal problem:

            And if I want to use the new style, I need lambda, right?

            Lambdas are a different thing...
            You can achieve the same result by connecting your button to your slot like this:

            connect(cboBox, &QComboBox::currentIndexChanged, this, &DailogTest::itemChanged);
            
            Q Offline
            Q Offline
            qcoderpro
            wrote on last edited by
            #5

            @Pl45m4

            It doesn't work because the slot has two different versions, one int and another a string.

            Error: no matching function

            Pl45m4P 1 Reply Last reply
            0
            • Q qcoderpro

              @Pl45m4

              It doesn't work because the slot has two different versions, one int and another a string.

              Error: no matching function

              Pl45m4P Offline
              Pl45m4P Offline
              Pl45m4
              wrote on last edited by
              #6

              @qcoderpro

              https://doc.qt.io/qt-5/qcombobox.html#currentIndexChanged


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply
              3
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You're looking for qOverload() I guess

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                2
                • Q Offline
                  Q Offline
                  qcoderpro
                  wrote on last edited by
                  #8

                  I use the old syntax. Thanks.

                  1 Reply Last reply
                  1

                  • Login

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