91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

Qt用Tcp 和Udp 傳圖片的例子,對于沒做過這方面編程的朋友肯定很有幫助

資源截圖

代碼片段和文件信息

/*
?*?Copyright?(c)?2006-2007?Johan?Thelin
?*?
?*?All?rights?reserved.
?*?
?*?Redistribution?and?use?in?source?and?binary?forms?with?or?without?modification?
?*?are?permitted?provided?that?the?following?conditions?are?met:
?*?
?*?????*?Redistributions?of?source?code?must?retain?the?above?copyright?notice?
?*???????this?list?of?conditions?and?the?following?disclaimer.
?*?????*?Redistributions?in?binary?form?must?reproduce?the?above?copyright?notice??
?*???????this?list?of?conditions?and?the?following?disclaimer?in?the?documentation?
?*???????and/or?other?materials?provided?with?the?distribution.
?*?????*?Neither?the?name?of?APress?nor?the?names?of?its?contributors?
?*???????may?be?used?to?endorse?or?promote?products?derived?from?this?software?
?*???????without?specific?prior?written?permission.
?*?
?*?THIS?SOFTWARE?IS?PROVIDED?BY?THE?COPYRIGHT?HOLDERS?AND?CONTRIBUTORS
?*?“AS?IS“?AND?ANY?EXPRESS?OR?IMPLIED?WARRANTIES?INCLUDING?BUT?NOT
?*?LIMITED?TO?THE?IMPLIED?WARRANTIES?OF?MERCHANTABILITY?AND?FITNESS?FOR
?*?A?PARTICULAR?PURPOSE?ARE?DISCLAIMED.?IN?NO?EVENT?SHALL?THE?COPYRIGHT?OWNER?OR
?*?CONTRIBUTORS?BE?LIABLE?FOR?ANY?DIRECT?INDIRECT?INCIDENTAL?SPECIAL
?*?EXEMPLARY?OR?CONSEQUENTIAL?DAMAGES?(INCLUDING?BUT?NOT?LIMITED?TO
?*?PROCUREMENT?OF?SUBSTITUTE?GOODS?OR?SERVICES;?LOSS?OF?USE?DATA?OR
?*?PROFITS;?OR?BUSINESS?INTERRUPTION)?HOWEVER?CAUSED?AND?ON?ANY?THEORY?OF
?*?LIABILITY?WHETHER?IN?CONTRACT?STRICT?LIABILITY?OR?TORT?(INCLUDING
?*?NEGLIGENCE?OR?OTHERWISE)?ARISING?IN?ANY?WAY?OUT?OF?THE?USE?OF?THIS
?*?SOFTWARE?EVEN?IF?ADVISED?OF?THE?POSSIBILITY?OF?SUCH?DAMAGE.
?*
?*/

#include?
#include?
#include?

#include?“clientdialog.h“

ClientDialog::ClientDialog()?:?QDialog()
{
??ui.setupUi(?this?);
??
??connect(?ui.getButton?SIGNAL(clicked())?this?SLOT(getClicked())?);
??
??connect(?&socket?SIGNAL(error(QAbstractSocket::SocketError))?this?SLOT(tcpError(QAbstractSocket::SocketError))?);
??connect(?&socket?SIGNAL(readyRead())?this?SLOT(tcpReady())?);
}

void?ClientDialog::getClicked()
{
??ui.getButton->setEnabled(?false?);
??
??ui.imageLabel->setPixmap(?QPixmap()?);
??ui.imageLabel->setText(?tr(“Getting?image...“)?);
??
??dataSize?=?0;
??
??socket.abort();
??socket.connectToHost(?ui.serverEdit->text()?9876?);
}

void?ClientDialog::tcpReady()
{
??if(?dataSize?==?0?)
??{
????QDataStream?stream(?&socket?);
????stream.setVersion(?QDataStream::Qt_4_0?);
??
????if(?socket.bytesAvailable()???????return;
??????
????stream?>>?dataSize;
??}
??
??if(?dataSize?>?socket.bytesAvailable()?)
????return;

??QByteArray?array?=?socket.read(?dataSize?);
??QBuffer?buffer(&array);
??buffer.open(?QIODevice::ReadOnly?);
??
??QImageReader?reader(&buffer?“PNG“);
??QImage?image?=?reader.read();

??if(?!image.isNull()?)
??{
????ui.imageLabel->setPixmap(?QPixmap::fromImage(?image?)?);
????ui.imageLabel->setText(?tr

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????1898??2007-08-04?17:35??udpserver\main.cpp

?????文件???????2682??2007-08-04?17:35??udpserver\sender.cpp

?????文件???????1933??2007-08-04?17:35??udpserver\sender.h

?????文件?????384731??2007-03-16?21:14??udpserver\test.png

?????文件????????377??2007-03-16?21:00??udpserver\udpserver.pro

?????文件???????3479??2007-08-04?17:35??tcpclient\clientdialog.cpp

?????文件???????2089??2007-08-04?17:35??tcpclient\clientdialog.h

?????文件???????4283??2007-08-04?17:33??tcpclient\clientdialog.ui

?????文件?????762136??2010-04-13?16:37??tcpclient\debug\clientdialog.o

?????文件?????723045??2010-04-13?16:37??tcpclient\debug\main.o

?????文件???????2433??2010-04-13?16:37??tcpclient\debug\moc_clientdialog.cpp

?????文件?????734581??2010-04-13?16:37??tcpclient\debug\moc_clientdialog.o

?????文件????1413139??2010-04-13?16:37??tcpclient\debug\tcpclient.exe

?????文件???????1837??2007-08-04?17:34??tcpclient\main.cpp

?????文件???????6259??2010-04-13?16:37??tcpclient\Makefile

?????文件???????6063??2010-04-13?16:37??tcpclient\Makefile.Debug

?????文件???????6137??2010-04-13?16:37??tcpclient\Makefile.Release

?????文件????????414??2007-02-01?16:14??tcpclient\tcpclient.pro

?????文件??????10346??2010-04-13?16:47??tcpclient\tcpclient.pro.user

?????文件???????6451??2010-04-13?16:37??tcpclient\ui_clientdialog.h

?????文件?????298820??2007-02-01?17:46??tcpserver\debug\images\test-green.png

?????文件?????327442??2007-01-17?17:31??tcpserver\debug\images\test.png

????..A.SH.??????9216??2010-04-13?16:37??tcpserver\debug\images\Thumbs.db

?????文件?????339868??2010-04-13?16:37??tcpserver\debug\main.o

?????文件?????424824??2010-04-13?16:37??tcpserver\debug\server.o

?????文件?????498358??2010-04-13?16:37??tcpserver\debug\serverthread.o

?????文件?????693560??2010-04-13?16:37??tcpserver\debug\tcpserver.exe

?????文件?????298820??2007-02-01?17:46??tcpserver\images\test-green.png

?????文件?????327442??2007-01-17?17:31??tcpserver\images\test.png

????..A.SH.????310272??2010-04-13?16:50??tcpserver\images\Thumbs.db

............此處省略27個文件信息

評論

共有 條評論