Exemple #1
0
receive_file::receive_file(QWidget *parent,QString msg,QString my,int portt) :
    QWidget(parent),
    ui(new Ui::receive_file)
{
    ui->setupUi(this);
    msg_from=msg;
    myname=my;
    port=portt;
    ///////////////////
    QPalette pal;
    QPixmap mypix(QDir::toNativeSeparators("./resorces/login.jpg"));
    pal.setBrush(QPalette::Window, QBrush(mypix));
    setPalette(pal);
    ////////////////////////



    trans=new QTcpSocket();///建立一个与文件传输server的链接;
    totalBytes = 0;
    bytesReceived = 0;
    fileNameSize = 0;

    connect(trans,SIGNAL(connected()),this,SLOT(start_tranfor()));
  //  connect(trans,SIGNAL(bytesWritten(qint64)),this,SLOT(update_clientprocess()));
    connect(trans,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(display_error(QAbstractSocket::SocketError)));
    connect(trans,SIGNAL(readyRead()),this,SLOT(update_clientprocess()));
}
void MainWindow::on_Show_clicked()
{
    img = new QImage(filePath);
    imgInfo = new image(img);
    QPixmap mypix(filePath);
    ui->label->setFixedSize(img->width(), img->height());
    ui->label->setPixmap(mypix);
}