我是级联编程的新手。我正在尝试开发一个可以给我接收和发送的字节数的应用程序。
我正在使用 QnetworkSession 方法bytesReceived()
和bytesWritten()
它,但得到错误。
任何帮助都是不言而喻的。
谢谢
代码:
#include "Monitor.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <QtCore/QFile>
#include <QtNetwork/QNetworkSession>
#include <QtNetwork/QNetworkConfiguration>
#include <QtNetwork/QNetworkConfigurationManager>
using namespace bb::cascades;
QNetworkSession::QNetworkSession ( const QNetworkConfiguration & connectionConfig, QObject * parent = 0 );
Monitor::Monitor(bb::cascades::Application *app)
: QObject(app)
{
QNetworkSession qnetworksession;
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("app", this);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
app->setScene(root);
}
quint64 Monitor::Received() const
{
quint64 rec=qnetworksession.bytesReceived ();
return(rec);
}
quint64 Monitor::Sent() const
{
quint64 sen=qnetworksession.bytesWritten ();
return(sen);
}