679
社区成员
发帖
与我相关
我的任务
分享
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
tcpSocket = new QTcpSocket(this);
tcpSocket->connectToHost("192.168.1.1",8080);
connect(tcpSocket,SIGNAL(readyRead()),this,SLOT(tcpDataReceive()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::tcpDataReceive()
{
QByteArray data = QByteArray::fromHex(tcpSocket->readAll());
qDebug() << data;
}
void MainWindow::on_pushButton_clicked()
{
tcpSocket->write("GET /?action=stream\r\n\r\n");
}
用QTcpSocket,再将接收到的数据剔除http header后用QPixmap在QLabel上绘图。