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. Passing parameters to slots
Forum Updated to NodeBB v4.3 + New Features

Passing parameters to slots

Scheduled Pinned Locked Moved General and Desktop
18 Posts 5 Posters 4.8k 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.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #8

    Ok thanks for the help!

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nicky j
      wrote on last edited by
      #9

      ok so I changed the connect function to:
      @connect(webView, SIGNAL(loadProgress(int)), SLOT(loadBar(int)));@
      It compiles, but doesn't seem to be called whenever the webView is loading.
      Im starting to think its trouble with the slot itself:

      @void browseTab::loadBar(int progress)
      {
      if(progress <= 25)
      {
      SearchBar->setStyleSheet(
      "border-right:2px solid blue;"
      );
      }
      if(progress == 50)
      {
      SearchBar->setStyleSheet(
      "border-right:2px solid blue;"
      "border-bottom:2px solid blue;"
      );
      }
      if(progress == 75)
      {
      SearchBar->setStyleSheet(
      "border-right:2px solid blue;"
      "border-bottom:2px solid blue;"
      "border-left:2px solid blue;"
      );
      }
      if(progress == 100)
      {
      SearchBar->setStyleSheet(
      "border-right:2px solid blue;"
      "border-bottom:2px solid blue;"
      "border-left:2px solid blue;"
      "border-top:2px solid blue;"
      );
      }
      if(progress == 101)
      {
      SearchBar->setStyleSheet(
      "border-right:2px solid black;"
      "border-bottom:2px solid black;"
      "border-left:2px solid black;"
      "border-top:2px solid black;"
      );
      }
      }@

      Basically I'm using the searchBar as a progress bar by changing the color of the sides as the page loads. Obviously it is not working. Ideas?

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

        To check if a slot is called, stick a qDebug() inside it.

        Also, you check if progress equals a particular value. Your slot won't do anything if it receives 49 or 51. It's best not to assume that every value between 1 and 100 will be received.

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

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nicky j
          wrote on last edited by
          #11

          yes int progress = 0. Should I change that? If not every value will be called, what should I do in the if() statements that are called when it reaches certain points? Is there a range of values I should call? if so, how do I do that?

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

            You don't get to choose which values you receive -- QWebView is responsible for that.

            Use qDebug() to print the value of progress each time your slot is called. That should help you decide what to do.

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

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nicky j
              wrote on last edited by
              #13

              ok I removed the default value from int progress. There is still nothing happening

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

                Use qDebug() to print progress. (Removing the default value should have no effect whatsoever)

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

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nicky j
                  wrote on last edited by
                  #15

                  where do I place qDebug()?

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

                    What debugging techniques are you familiar with? Have you used printf() before?

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

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      nicky j
                      wrote on last edited by
                      #17

                      nope Ive never used printf() or qDebug() before

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

                        See "QDebug | Basic Use":http://qt-project.org/doc/qt-5/QDebug.html#basic-use for an example.

                        It is a very simple but very useful technique to check your program. If you put qDebug() in a function, it will print a message in your Application Output pane* every time that function is called. If the message doesn't appear, that means your function hasn't been called. once you play with it, I'm sure you can think of other uses for qDebug().

                        Use qDebug() to:

                        Check if loadBar() is called

                        Examine the value of progress inside loadBar()

                        *(If you don't know where the Application Output pane is, search the "Qt Creator | User Interface":http://qt-project.org/doc/qtcreator-3.0/creator-quick-tour.html#application-output page)

                        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