Note that there are some explanatory texts on larger screens.

plurals
  1. POQNetworkRequest (HTTP GET) doesn't fire, after refactoring into a standalone class
    text
    copied!<p>I've recently began the tedious process of modularising a large, monolithic audio player application that I wrote roughly 2 months ago. </p> <p>This process is going reasonably well, although it appears that one of the methods (ScrobbleMedia - which predictably enough makes HTTP requests to submit information about a playing track to last.fm) no longer seems to make network requests. </p> <p>However, the QUrl object that would be passed through to the QNetworkAccessManager instance/QNetworkRequest is being built correctly.</p> <p>For comparison, a functional Mercurial revision of the code is available on <a href="https://bitbucket.org/vmlemon/audioplayer/src/b655a64e824a/audioplayer.cpp" rel="nofollow">BitBucket</a>.</p> <p>The ScrobbleMedia method currently looks like this, after refactoring:</p> <pre><code>#include "scrobblemedia.h" #include &lt;QDebug&gt; #include &lt;cstdio&gt; ScrobbleMedia::ScrobbleMedia(QString asUsername, QString asPassword, QString asArtist, QString asTrack, QString asAlbum) { QString KEndPointURL = "http://lastfmstats.livefrombmore.com/universalscrobbler/scrobble.php"; QUrl iScrobbleEndPoint(KEndPointURL); QNetworkAccessManager *iScrobbleDispatcher = new QNetworkAccessManager(this); iScrobbleEndPoint.addQueryItem("submissionType","track"); iScrobbleEndPoint.addQueryItem("username", asUsername); iScrobbleEndPoint.addQueryItem("password", asPassword); iScrobbleEndPoint.addQueryItem("artist", asArtist); iScrobbleEndPoint.addQueryItem("track", asTrack); iScrobbleEndPoint.addQueryItem("album", asAlbum); iScrobbleEndPoint.addQueryItem("number","1"); iScrobbleEndPoint.addQueryItem("duration","200"); iScrobbleDispatcher-&gt;get(QNetworkRequest(iScrobbleEndPoint)); connect(iScrobbleDispatcher, SIGNAL(finished(QNetworkReply*)), SLOT(replyFinished(QNetworkReply*))); // QString Outside = iScrobbleEndPoint.toEncoded(); qDebug() &lt;&lt; "Received: " + asUsername + " " + asPassword + " " + asArtist + " " + asTrack + " " + asAlbum; qDebug() &lt;&lt; iScrobbleEndPoint.toString(); } ScrobbleMedia::~ScrobbleMedia() { } </code></pre> <p>The associated header file looks like:</p> <pre><code>#ifndef SCROBBLEMEDIA_H #define SCROBBLEMEDIA_H #include &lt;QString&gt; #include &lt;QtNetwork&gt; #include &lt;QUrl&gt; #include &lt;QNetworkAccessManager&gt; class ScrobbleMedia : public QObject { Q_OBJECT; private: public: ScrobbleMedia(QString asUsername, QString asPassword, QString asArtist, QString asTrack, QString asAlbum); ~ScrobbleMedia(); }; #endif // SCROBBLEMEDIA_H </code></pre> <p>I'm currently building the application itself against a MinGW build of version 4.7.0 of the Qt libraries (included as part of Qt SDK 2010.05) under Windows 7 x86-64.</p> <p>Any assistance would be appreciated.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload