Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Debug Help: How to find the source of QT SIGNAL?
QtWS25 Last Chance

Debug Help: How to find the source of QT SIGNAL?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 4 Posters 6.4k 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.
  • E Offline
    E Offline
    Eric Ruei
    wrote on last edited by
    #1

    Hi, Experts:

    I am debugging a QT5 issue for QT demo browser at \examples\webkitwidgets\browser.
    The issue is that the webpage loading is terminated before it is completed for some reason.

    Received finished signal while progress is still: 10 Url: QUrl("http://10.4.1.14/")

    WebView::WebView(QWidget* parent)
    {
    …
    connect(this, SIGNAL(loadFinished(bool)),
    this, SLOT(loadFinished()));
    …
    }

    It is clear that someone triggers (emits) the SIGNAL(loadFinished(bool)). If I can find the source, then I shall be able to find out why it is triggered prematurely. But I am not able to find out which code sends this SIGNAL. Is there a way to find out the source of QT signals?

    Best regards,

    Eric Ruei

    1 Reply Last reply
    0
    • yuvaramY Offline
      yuvaramY Offline
      yuvaram
      wrote on last edited by
      #2

      Hi,

      In the slot you can use

      QObject *obj = this->sender();
      qDebug()<<"objName ::"<<obj->objectName()<<endl;

      Yuvaram Aligeti
      Embedded Qt Developer
      : )

      E 1 Reply Last reply
      0
      • yuvaramY yuvaram

        Hi,

        In the slot you can use

        QObject *obj = this->sender();
        qDebug()<<"objName ::"<<obj->objectName()<<endl;

        E Offline
        E Offline
        Eric Ruei
        wrote on last edited by
        #3

        @yuvaram

        Thank you so much!
        Unfortunately, the objName is Null.
        objName :: ""

        Best regards,

        Eric

        yuvaramY 1 Reply Last reply
        0
        • E Eric Ruei

          @yuvaram

          Thank you so much!
          Unfortunately, the objName is Null.
          objName :: ""

          Best regards,

          Eric

          yuvaramY Offline
          yuvaramY Offline
          yuvaram
          wrote on last edited by
          #4

          @Eric-Ruei
          The signals used for this slot ,try to assign object name using ,
          setObjectName();
          Then try above methods.

          Yuvaram Aligeti
          Embedded Qt Developer
          : )

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mvuori
            wrote on last edited by
            #5

            AFIK the sender() works only if a signal was emitted. It could be that the slot is called by a regular method call. In that case you can use regular debugger techniques.

            1 Reply Last reply
            0
            • Paul ColbyP Offline
              Paul ColbyP Offline
              Paul Colby
              wrote on last edited by
              #6

              AFIK the sender() works only if a signal was emitted.

              True, but in this case, sender must be working, or the dereference would (most likely) be segfaulting, rather than return an empty QString.

              In my experience, most QObject's have no name unless you set one yourself. However, they should all have a class-name.

              Try adding something like:

              Q_CHECK_PTR(obj);
              qDebug() << "objClass ::" << obj->metaObject()->className();
              qDebug() << "method ::" << obj->metaObject()->method(senderSignalIndex())->methodSignature();
              

              (Error checks omitted for brevity)

              Cheers.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Eric Ruei
                wrote on last edited by
                #7

                Thanks everyone for your help.
                To debug why the webpage load failed, I am trying to find which piece of code trigger the loadFinished() SIGNAL.
                With all your help, I am able to find the class of the sender, which happens to be the one where the slot function runs.

                QPixmap::scaled: Pixmap is a null pixmap
                QPixmap::scaled: Pixmap is a null pixmap
                WebView::setProgress: 74
                WebView::setProgress: 100
                WebView::loadFinished:
                objClass :: WebView

                void WebView::loadFinished()
                {
                QObject *obj = this->sender();

                if (100 != m_progress) {
                    qWarning() << "Received finished signal while progress is still:" << progress()
                               << "Url:" << url();
                }
                qWarning() << "WebView::loadFinished:";
                Q_CHECK_PTR(obj);
                qDebug() << "objClass ::" << obj->metaObject()->className();
                //qDebug() << "method ::" << obj->metaObject()->method(senderSignalIndex())->methodSignature();    
                m_progress = 0;
                

                }

                And the signal/slot connection is declared at the class constructor as the followings:
                connect(this, SIGNAL(loadFinished(bool)),
                this, SLOT(loadFinished()));

                Therefore, it make sense that the sender and receiver belong to the same object. And I should test it out by assign an object name.

                I cannot find where the loadFinished SIGNAL is emitted or triggered somehow in this class.
                It will be highly appreciated for any further assistance!
                This is the QT5 standard demo browser example at qt5\examples\webkitwidgets\browser, not our own code.

                Best regards,

                Eric

                1 Reply Last reply
                0
                • E Offline
                  E Offline
                  Eric Ruei
                  wrote on last edited by
                  #8

                  Thank you so much for the kind assistance from all of you!
                  I finally find the place where loadFinished() Signal is emitted.

                  "QWebFramePrivate::emitLoadFinished call loadFinished with: false"

                  I realized that the signal loadFinished() is not defined at WebView, but QWebView and the signal should be emitted.
                  With a search and a few QDebug() trace, I am able to find the interesting code section.

                  Best regards,

                  Eric Ruei

                  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