added first network things
This commit is contained in:
@@ -1,14 +1,55 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
#include <qnetwork.h>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
class QNetworkReply;
|
||||
namespace yremote {
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
manager = new QNetworkAccessManager(this);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::func()
|
||||
{
|
||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||
connect(manager, SIGNAL(finished(QNetworkReply*)),
|
||||
this, SLOT(replyFinished(QNetworkReply*)));
|
||||
|
||||
manager->get(QNetworkRequest(QUrl("http://qt-project.org")));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_btn_onoff_clicked()
|
||||
{
|
||||
qDebug() << "void MainWindow::on_btn_onoff_clicked()";
|
||||
sendCommand("<YAMAHA_AV cmd=\"GET\"><Main_Zone><Input><Input_Sel>GetParam</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
|
||||
}
|
||||
|
||||
QString MainWindow::sendCommand(QString cmd)
|
||||
{
|
||||
QString res;
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setUrl("http://" + mAddress + ":80/YamahaRemoteControl/ctrl");
|
||||
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
qDebug() << reply->readAll();
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
void yremote::MainWindow::on_txt_address_textEdited(const QString &arg1)
|
||||
{
|
||||
mAddress = arg1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user