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] Signals and Slots ... again
Forum Update on Monday, May 27th 2025

[solved] Signals and Slots ... again

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.0k Views
  • 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.
  • S Offline
    S Offline
    secretNinja
    wrote on last edited by
    #1

    I have read so many threads, wikis and so on for Signals and Slots but I still can't make it work in my app.

    I'm not even sure that the logic of my app is OK. So here is the logic:

    • I have a class 'downloader' which connects to Internet and download some things;
    • another class 'sumcclient' which using some logic ask the downloader to give it some info from Internet
    • I have a QTextEdit in which I want to publish the downloaded info.

    What I'm doing:

    • When the program starts:
      @sumcClient sumc;
      connect( &sumc, SIGNAL( contentReady(QString) ), ui->uiInformation, SLOT( insertHtml(QString) ));@

    • contentReady is emitted in the sumclient class when the information is downloaded: @connect( down, SIGNAL( downloaded(QString) ) , this, SIGNAL( contentReady(QString) ));@

    • and info is downloaded when: @connect( reply, SIGNAL( finished() ), this, SLOT( finishedDownload() ) );@

    • in finishedDownload() it is emitted "download(QString)" signal where the QString should be the info.

    The problem is that the signals and slots stop communicating ( I'm doing something wrong .. of course ):

    QNetworkReply is sent and received -> then finished() signal is emitted and finishDownload() is called

    in finishDownload() it is emitted 'Downloaded(QString)' signal

    then I suppose that 'contentReady(QString)' should be emittted with the same content as 'Downloaded(QSting)'

    and then as this signal is connected to the 'insertHtml(QString)' slot of the QTextEdit ... I want the info to appear into the TextEdit.

    The whole source of the app is in this "git repo":https://github.com/SecretNinja/OnTime . Is it needed to clarify my question?

    Thank you :)

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      The code in your github repo doesn't have the signals yet. Your connect statements will tell you the connection has therefore failed.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        secretNinja
        wrote on last edited by
        #3

        I'm sorry ... I thought that it was committed. Now there is commit named "Signals and Slots".

        The main difference is in this files:
        "mainwindow.cpp":http://github.com/SecretNinja/OnTime/blob/master/mainwindow.cpp
        "downloader.cpp":http://github.com/SecretNinja/OnTime/blob/master/downloader.cpp
        "sumcclient.cpp":http://github.com/SecretNinja/OnTime/blob/master/sumcclient.cpp

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          Do you get any Object::connect messages in your application output while debugging?

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • S Offline
            S Offline
            secretNinja
            wrote on last edited by
            #5

            This is all the output I have:
            @Starting C:\Coding\Qt\OnTime-build-simulator\debug\OnTime.exe...
            startRequest() for "http://m.sumc.bg/vt?q=1287&go=1"
            before sumcClient
            asisted sumcClient
            finishedDownload() for "http://m.sumc.bg/vt?q=1287&go=1"
            emitted downloaded
            C:\Coding\Qt\OnTime-build-simulator\debug\OnTime.exe exited with code 0@

            1 Reply Last reply
            0
            • L Offline
              L Offline
              leon.anavi
              wrote on last edited by
              #6

              Hi,

              I had a quick glance at your code. I saw that you emit downloaded successfully. Signal downloaded is connected to signal contentReady and in MainWindow contentReady is connected to slot insertHtml, right?

              Is the contentReady signal also emitted successfully? Is everything with the QTextEdit ui->uiInformation OK?

              Best regards,
              Leon

              http://anavi.org/

              1 Reply Last reply
              0
              • S Offline
                S Offline
                secretNinja
                wrote on last edited by
                #7

                Yes, that's right.

                As you said downloaded is connected to contentReady and it should be emitted but I think this is the place where something goes wrong.

                It seems to me that there is no problem with the QTextEdit:

                • manually I could set its content;
                • I create another signal ( and connected it with insertHtml ) in sumcClient class ( contentReady is there too ) and emitted it with some text and it is displayed in the QTextEdit.

                So this is the problem:
                @connect( down, SIGNAL( downloaded(QString)) , this, SIGNAL(contentReady(QString)));@

                If downloaded is emitted, why contentReady is not?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  secretNinja
                  wrote on last edited by
                  #8

                  OK ... I've just solved my issue. I am still not sure exactly which of the things I changed help me.

                  I will test a little bit more and will write what the problem was.

                  Thank you :) Explaining my problem and the question you've asked me made me think what and where is the problem :)

                  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