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. [solved] "No such slot" error
Qt 6.11 is out! See what's new in the release blog

[solved] "No such slot" error

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 13.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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi all. I have a problem, that I can't solve.
    I have class MainWindow and I have two slots in private slots section:
    @ void getData(QUrl url, QScrollArea *object);
    void proccessData(QNetworkReply *pReply, QScrollArea *object);@
    There are source codes of this slots:
    @void MainWindow::getData(QUrl url, QScrollArea object)
    {
    static QNetworkAccessManager am;
    QNetworkRequest request(url);
    QNetworkReply
    reply = am.get(request);
    connect(reply,SIGNAL(finished()),
    this,SLOT(proccessData(reply,object)));
    }
    void MainWindow::proccessData(QNetworkReply *pReply, QScrollArea object)
    {
    QLabel
    label = new QLabel;
    label->setText(pReply->readAll());
    object->setWidget(label);
    }@

    My app compiles without any errors, but when I "getData" calls "processData", I see that in my debug window
    @Object::connect: No such slot MainWindow::proccessData(reply,object) in ..\MainWindow.cpp:166@

    Also I have QScrollArea without any text. Please, help me

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Maybe the problem is the connect inside the getData slot. You could try to put it in constructor.

      Hope it helps you.

      Regards.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MuldeR
        wrote on last edited by
        #3

        Your slot function is defined as
        @proccessData(QNetworkReply*, QScrollArea*)@

        But you try to connect to, so indeed there is no such slot!
        @SLOT(proccessData(reply,object))@

        You need to change that to:
        @SLOT(proccessData(QNetworkReply*, QScrollArea*))@

        Also you may consider changing your function's signature to:
        @proccessData(const QNetworkReply &reply const QScrollArea &area)@

        My OpenSource software at: http://muldersoft.com/

        Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

        Go visit the coop: http://youtu.be/Jay...

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          [quote author="BelenMuñoz" date="1359043115"]Maybe the problem is the connect inside the getData slot. You could try to put it in constructor.

          Hope it helps you.

          Regards.[/quote]

          But *reply is the local variable. How I can put in it the constructor?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            [quote author="MuldeR" date="1359043460"]Your slot function is defined as
            @proccessData(QNetworkReply*, QScrollArea*)@

            But you try to connect to
            @SLOT(proccessData(reply,object)@

            You need to change that to:
            @SLOT(proccessData(QNetworkReply*, QScrollArea*)@[/quote]

            thanks, I will try it

            1 Reply Last reply
            0
            • JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              Edit: MuldeR beat me to item #1!

              [quote author="bio120" date="1359042834"]
              @
              connect(reply,SIGNAL(finished()),
              this,SLOT(proccessData(reply,object)));
              @
              [/quote]

              Hi bio120,

              Two things to fix:

              1. The slot signature needs to contain the TYPES of the parameters, not the VARIABLE NAMES:
                @
                // Correct:
                SLOT(proccessData(QNetworkReply*,QScrollArea*))

              // Wrong:
              SLOT(proccessData(reply,object))
              @

              1. Signals and slots must have matching parameters. Since your signal finished() has no parameters, your slot cannot have any parameters either. So, you can't connect QNetworkReply::finished() to MainWindow::proccessData(QNetworkReply*, QScrollArea*)

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                JKSH,thanks. it's the best answer.

                1 Reply Last reply
                0
                • JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #8

                  You're welcome.

                  To clarify point #2: You can't pass a local variable into a slot's connection. If you want to pass an argument into a slot, that argument must be emitted with the signal, e.g.

                  @
                  connect(calculator, SIGNAL(result(int)), this, SLOT(processResult(int)));
                  @

                  In the above example, processResult() copies the int that was provided by result().

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  0

                  • Login

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