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. Youtube API in Qt
Forum Updated to NodeBB v4.3 + New Features

Youtube API in Qt

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.3k 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.
  • B Offline
    B Offline
    b1gsnak3
    wrote on last edited by
    #1

    Hello again :)

    Anyone know how can I use the Youtube API and create a somewhat custom search in a widget? Something similar to the android youtube search... I do not want to add the whole page in a QWebView(that is easy) because I need the search to be rather small... Something like 300x300 px... Maybe scalable but the minimum width something like that.. I got the query results in a XML format but I don't know what to do from there on...

    Thank you in advance.

    Qt 4.8.4 (or 5.0)
    Windows 7

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Use the youtube API's https://developers.google.com/youtube/getting_started#data_api

      You will need to write your own Qt-wrapper for these but should not be particularly difficult. Qt provides all the building blocks that you need.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b1gsnak3
        wrote on last edited by
        #3

        thank you. my problem wasn't with the youtube api... it was with writting the wrapper though :)

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Ah, sorry I misunderstood. QNetworkAccessManager is your friend in this case. Wrap this up in your own class and add member functions that map onto requests using the youtube API.

          Or do you have a more specific problem with doing this type of thing?

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • B Offline
            B Offline
            b1gsnak3
            wrote on last edited by
            #5

            The problem i'm having is constructing a custom widget in which to display the results of the query I get from youtube API. it's more of a XML problem now that I think of it... Not so much in the API. I'm not certain on how to reconstruct parts of the XML in my custom widget :) I think I should use the QDeclarativeView class (not certain) to add the XML. Am I even close to the solution? :D

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #6

              OK I see what you are getting at now. What I would suggest is something along these lines:

              Construct a class that issues the API calls to youtube

              When the data is returned to you process the XML (I assume it is xml from what you said) using QXmlStreamReader.

              Create a class that inherits from QAbstractListModel. Populate this list with items from contained in your xml (i.e. search results).

              If you are using QML (which sounds like it will be a good fit in this case), create a QML document that contains a ListView element along with a custom delegate element (this gets created for each item in your list model).

              From C++ expose your list model of results to QML using QDeclarativeContext::setContextProperty()

              In QML set the "model" property of your list to the id of your exported model.

              That is the basic setup. Of course you can go further by having a TextInput QML element to control what to search for on youtube etc.

              Take a look at some of the QML examples with custom C++ list models that ships with Qt.

              Please feel free to come back with specific questions on the above steps.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              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