filetransfer.cpp Example File
picturetransfer/filetransfer.cpp
#include "filetransfer.h"
#include <QFile>
#include <QBluetoothTransferReply>
#include <QDebug>
FileTransfer::FileTransfer(QObject *parent) :
QObject(parent), m_progress(0)
{
}
void FileTransfer::initTransfer(QString address, QString fileName)
{
qDebug() << "Begin sharing file: " << address << fileName;
QBluetoothAddress btAddress = QBluetoothAddress(address);
QBluetoothTransferRequest request(btAddress);
QFile *file = new QFile(fileName);
reply = manager.put(request, file);
connect(reply, SIGNAL(transferProgress(qint64,qint64)), this, SLOT(updateProgress(qint64,qint64)));
}
void FileTransfer::updateProgress(qint64 transferred, qint64 total)
{
m_progress = ((float)transferred)/((float)total);
emit progressChanged();
}