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. undefined reference to
Forum Updated to NodeBB v4.3 + New Features

undefined reference to

Scheduled Pinned Locked Moved General and Desktop
14 Posts 6 Posters 7.4k 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.
  • K Offline
    K Offline
    kamalakshantv
    wrote on last edited by
    #3

    [quote author="sathism" date="1293777356"]@
    namespace The {
    NetworkAccess* http();
    }

    Video::Video() : m_duration(0),
    m_viewCount(-1),
    definitionCode(0),
    elIndex(0),
    loadingStreamUrl(false)
    { }
    @

    [/quote]

    Also what does this lines do. Are they inside any function.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BlackDante
      wrote on last edited by
      #4

      [quote author="QtK" date="1293783653"]
      [quote author="sathism" date="1293777356"]@
      namespace The {
      NetworkAccess* http();
      }

      Video::Video() : m_duration(0),
      m_viewCount(-1),
      definitionCode(0),
      elIndex(0),
      loadingStreamUrl(false)
      { }
      @

      [/quote]

      Also what does this lines do. Are they inside any function.
      [/quote]

      I think that this is a construct function with list of initialization(i don't sure how it's named in english) from class Video who is in video.h file

      sorry for my broken english :)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kamalakshantv
        wrote on last edited by
        #5

        [quote author="BlackDante" date="1293791754"]
        [quote author="QtK" date="1293783653"]
        [quote author="sathism" date="1293777356"]@
        namespace The {
        NetworkAccess* http();
        }

        Video::Video() : m_duration(0),
        m_viewCount(-1),
        definitionCode(0),
        elIndex(0),
        loadingStreamUrl(false)
        { }
        @

        [/quote]

        Also what does this lines do. Are they inside any function.
        [/quote]

        I think that this is a construct function with list of initialization(i don't sure how it's named in english) from class Video who is in video.h file [/quote]

        Oh no it seems I am gone blind :) I didn't notice this Video::Video() properly.

        Thank you.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsorokin
          wrote on last edited by
          #6

          QtK, BlackDante are right, It's implementation empty constructor with list of initialization values.

          --
          Vasiliy

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kamalakshantv
            wrote on last edited by
            #7

            [quote author="Vass" date="1293792450"]QtK, BlackDante are right, It's implementation empty constructor with list of initialization values.[/quote]

            Yes, As mentioned above I had not noticed it properly. Don't know how I missed it.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              BlackDante
              wrote on last edited by
              #8

              This is no problem, sometimes everyone can miss somethink. :) it's in human nature :)

              sorry for my broken english :)

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #9

                [quote author="Vass" date="1293779836"]@namespace The {
                NetworkAccess* http();
                }@

                You declare this function, but nowhere implemented it.[/quote]

                This should be the problem. Something like this should solve it:

                @
                #include "video.h"
                #include "networkaccess.h"
                #include <QtNetwork>
                #include "videodefinition.h"

                namespace The {
                NetworkAccess* http()
                {
                return 0;
                }
                }

                Video::Video() :
                m_duration(0),
                m_viewCount(-1),
                definitionCode(0),
                elIndex(0),
                loadingStreamUrl(false)
                { }

                void Video::preloadThumbnail()
                {
                if (m_thumbnailUrls.isEmpty()) return;
                QObject *reply = The::http()->get(m_thumbnailUrls.first());
                connect(reply, SIGNAL(data(QByteArray)), SLOT(setThumbnail(QByteArray)));
                }
                @

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • ZlatomirZ Offline
                  ZlatomirZ Offline
                  Zlatomir
                  wrote on last edited by
                  #10

                  Please ignore if you actually want the http to be a function
                  But i have a feeling that the OP didn't want a function there, so here is my explanation about this line of code:
                  @NetworkAccess* http();@
                  The C++ compiler threats all the "things" that might be a function declaration, like there really are function declaration, so the compiler thinks: NetworkAccess pointer is the return type, http is the function name and () the function has no parameters.

                  If you want an object on the stack you will write this:
                  @NetworkAccess http; //no pointer and no () for default constructor
                  @
                  If you want/need to use pointers, you need two objects: the pointer and the object itself, that is done usually by using the operator new to allocate memory and call the constructor of the object (or using the address-of operator to take the address of a previously created object), code (for operator new) looks like this:
                  @NetworkAccess* http = new NetworkAccess(); //here you can have () for default constructor ;)
                  @

                  https://forum.qt.io/category/41/romanian

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sathism
                    wrote on last edited by
                    #11

                    Thanks for all your valuable replies.
                    @Gerolf
                    I will try your fix ..

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vsorokin
                      wrote on last edited by
                      #12

                      [quote author="Gerolf" date="1293806305"]
                      This should be the problem. Something like this should solve it:

                      @
                      #include "video.h"
                      #include "networkaccess.h"
                      #include <QtNetwork>
                      #include "videodefinition.h"

                      namespace The {
                      NetworkAccess* http()
                      {
                      return 0;
                      }
                      }

                      Video::Video() :
                      m_duration(0),
                      m_viewCount(-1),
                      definitionCode(0),
                      elIndex(0),
                      loadingStreamUrl(false)
                      { }

                      void Video::preloadThumbnail()
                      {
                      if (m_thumbnailUrls.isEmpty()) return;
                      QObject *reply = The::http()->get(m_thumbnailUrls.first());
                      connect(reply, SIGNAL(data(QByteArray)), SLOT(setThumbnail(QByteArray)));
                      }
                      @[/quote]

                      Gerolf, you code will be crashed on line 25:
                      @ QObject *reply = The::http()->get(m_thumbnailUrls.first());@
                      because The::http() return null pointer.

                      --
                      Vasiliy

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #13

                        It was to show, what is missing. I didn't implement the method, that's something you have to do :-)

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vsorokin
                          wrote on last edited by
                          #14

                          Gerolf I understood :) I just saw sathism will try your fix, and warned about problem.

                          --
                          Vasiliy

                          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