• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ readyRead函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中readyRead函数的典型用法代码示例。如果您正苦于以下问题:C++ readyRead函数的具体用法?C++ readyRead怎么用?C++ readyRead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readyRead函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: qsrand

//--------------------------------------------------------------------------------------------
void MArduinoConnector::InitPort()
{
qsrand(1234578);

//  QSerialPort* pSerialPort = new QSerialPort(this);
//  QString sp;
  PStringMessage->clear();

  QString portName;//("COM4");
  foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
    if(info.description() == NameDevice) {
      portName = info.portName();
      *PStringMessage = info.description() + ":\n"
                      + QObject::tr("     Port: ") + info.portName() + "\n"
                      + QObject::tr("     Location: ") + info.systemLocation() + "\n"
//                      + QObject::tr("Description: ") + info.description() + "\n"
                      + QObject::tr("     Manufacturer: ") + info.manufacturer() + "\n"
                      + QObject::tr("     Vendor Identifier: ") + (info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) + "\n"
                      + QObject::tr("     Product Identifier: ") + (info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()) + "\n"
                      + QObject::tr("     Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) + "\n";
//QMessageBox msgBox;  msgBox.setText(sp);  msgBox.exec();
//  *PStringMessage = sp;
//      emit SignalMessage(PStringMessage);
      break;
    }
  }

  if(portName.isEmpty()) {
    *PStringMessage = NameDevice;  *PStringMessage += " is not connected.";
  }
  else {
    PPort = new QSerialPort(this);

//  connect(PPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(SlotPortError(QSerialPort::SerialPortError)));

    PPort->setPortName(portName);
    if(PPort->open(QIODevice::ReadWrite)) { // | QIODevice::Text)) { // | QIODevice::Unbuffered)) { //QIODevice::WriteOnly))  {
      PPort->setBaudRate(QSerialPort::Baud38400);//38400);
      PPort->setDataBits(QSerialPort::Data8);
      PPort->setParity(QSerialPort::NoParity);
      PPort->setStopBits(QSerialPort::OneStop);
      PPort->setFlowControl(QSerialPort::NoFlowControl); // QSerialPort::SoftwareControl

      PPort->setReadBufferSize(64);
//    PPort->clear(QSerialPort::AllDirections);

//    QMessageBox msgBox;  msgBox.setText("Port \""+portName+"\" is open");  msgBox.exec();
      *PStringMessage += "\nPort \""+portName+"\" is open.\n";

      connect(PPort, SIGNAL(readyRead()), SLOT(SlotReadyRead()));
    }
    else {
//    QMessageBox msg;  msg.setText("Port \""+portName+"\" is not open");  msg.exec();
      *PStringMessage += "\nPort \""+portName+"\" is not open.\n";

      delete PPort;  PPort = NULL;
    }
  }

  emit SignalMessage(PStringMessage);
}
开发者ID:stormbringerdp1,项目名称:WIGTSv3,代码行数:62,代码来源:MArduinoConnector.cpp


示例2: while

void InspectorServerRequestHandlerQt::tcpReadyRead()
{
    WebKit::QHttpRequestHeader header;
    bool isWebSocket = false;
    if (!m_tcpConnection)
        return;

    if (!m_endOfHeaders) {
        while (m_tcpConnection->bytesAvailable() && !m_endOfHeaders) {
            QByteArray line = m_tcpConnection->readLine();
            m_data.append(line);
            if (line == "\r\n")
                m_endOfHeaders = true;
        }
        if (m_endOfHeaders) {
            header = WebKit::QHttpRequestHeader(QString::fromLatin1(m_data));
            if (header.isValid()) {
                m_path = header.path();
                m_contentType = header.contentType().toLatin1();
                m_contentLength = header.contentLength();
                if (header.hasKey(QLatin1String("Upgrade")) && (header.value(QLatin1String("Upgrade")) == QLatin1String("WebSocket")))
                    isWebSocket = true;

                m_data.clear();
            }
        }
    }

    if (m_endOfHeaders) {
        QStringList pathAndQuery = m_path.split(QLatin1Char('?'));
        m_path = pathAndQuery[0];
        QStringList words = m_path.split(QLatin1Char('/'));

        if (isWebSocket) {
            // switch to websocket-style WebSocketService messaging
            if (m_tcpConnection) {
                m_tcpConnection->disconnect(SIGNAL(readyRead()));
                connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(webSocketReadyRead()), Qt::QueuedConnection);

                QByteArray key3 = m_tcpConnection->read(8);

                quint32 number1 = parseWebSocketChallengeNumber(header.value(QLatin1String("Sec-WebSocket-Key1")));
                quint32 number2 = parseWebSocketChallengeNumber(header.value(QLatin1String("Sec-WebSocket-Key2")));

                char responseData[16];
                generateWebSocketChallengeResponse(number1, number2, (unsigned char*)key3.data(), (unsigned char*)responseData);
                QByteArray response(responseData, sizeof(responseData));

                WebKit::QHttpResponseHeader responseHeader(101, QLatin1String("WebSocket Protocol Handshake"), 1, 1);
                responseHeader.setValue(QLatin1String("Upgrade"), header.value(QLatin1String("Upgrade")));
                responseHeader.setValue(QLatin1String("Connection"), header.value(QLatin1String("Connection")));
                responseHeader.setValue(QLatin1String("Sec-WebSocket-Origin"), header.value(QLatin1String("Origin")));
                responseHeader.setValue(QLatin1String("Sec-WebSocket-Location"), (QLatin1String("ws://") + header.value(QLatin1String("Host")) + m_path));
                responseHeader.setContentLength(response.size());
                m_tcpConnection->write(responseHeader.toString().toLatin1());
                m_tcpConnection->write(response);
                m_tcpConnection->flush();

                if ((words.size() == 4)
                    && (words[1] == QString::fromLatin1("devtools"))
                    && (words[2] == QString::fromLatin1("page"))) {
                    int pageNum = words[3].toInt();

                    m_inspectorClient = m_server->inspectorClientForPage(pageNum);
                    // Attach remoteFrontendChannel to inspector, also transferring ownership.
                    if (m_inspectorClient)
                        m_inspectorClient->attachAndReplaceRemoteFrontend(this);
                }

            }

            return;
        }
        if (m_contentLength && (m_tcpConnection->bytesAvailable() < m_contentLength))
            return;

        QByteArray content = m_tcpConnection->read(m_contentLength);
        m_endOfHeaders = false;

        QByteArray response;
        int code = 200;
        QString text = QString::fromLatin1("OK");

        // If no path is specified, generate an index page.
        if (m_path.isEmpty() || (m_path == QString(QLatin1Char('/')))) {
            QString indexHtml = QLatin1String("<html><head><title>Remote Web Inspector</title></head><body><ul>\n");
            for (QMap<int, InspectorClientQt* >::const_iterator it = m_server->m_inspectorClients.begin();
                 it != m_server->m_inspectorClients.end(); 
                 ++it) {
                indexHtml.append(QString::fromLatin1("<li><a href=\"/webkit/inspector/inspector.html?page=%1\">%2</li>\n")
                                 .arg(it.key())
                                 .arg(it.value()->m_inspectedWebPage->mainFrame()->url().toString()));
            }
            indexHtml.append(QLatin1String("</ul></body></html>"));
            response = indexHtml.toLatin1();
        } else {
            QString path = QString::fromLatin1(":%1").arg(m_path);
            QFile file(path);
            // It seems that there should be an enum or define for these status codes somewhere in Qt or WebKit,
            // but grep fails to turn one up.
//.........这里部分代码省略.........
开发者ID:dzhshf,项目名称:WebKit,代码行数:101,代码来源:InspectorServerQt.cpp


示例3: QObject

MaiaXmlRpcServerConnection::MaiaXmlRpcServerConnection(QTcpSocket *connection, QObject* parent) : QObject(parent) {
	header = NULL;
	clientConnection = connection;
	connect(clientConnection, SIGNAL(readyRead()), this, SLOT(readFromSocket()));
    connect(clientConnection, SIGNAL(disconnected()), this, SLOT(deleteLater()));
}
开发者ID:wiedi,项目名称:libmaia,代码行数:6,代码来源:maiaXmlRpcServerConnection.cpp


示例4: logStatusMessage


//.........这里部分代码省略.........
                    win.logMessage(error);
                    win.stopServer();
                    throw error;
                }
            }
            logMessage(tr("Loaded %1 quests/npcs").arg(nQuests));
        }
        catch (QString& e)
        {
            enableGameServer = false;
        }
    }

    /// Read/parse mob zones
    if (enableGameServer)
    {
        try
        {
            QDir mobsDir(MOBSPATH);
            QStringList files = mobsDir.entryList(QDir::Files);
            for (int i=0; i<files.size(); i++) // For each mobzone file
            {
                QFile file(MOBSPATH+files[i]);
                if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
                {
                    logStatusMessage(tr("Error reading mob zones"));
                    return;
                }
                QByteArray data = file.readAll();
                file.close();
                try {
                    parseMobzoneData(data); // Will fill our Mobzone and Mobs list
                }
                catch (QString& error)
                {
                    win.logMessage(error);
                    win.stopServer();
                    throw error;
                }
            }
            logMessage(tr("Loaded %1 mobs in %2 zones").arg(mobs.size()).arg(mobzones.size()));
        }
        catch (...) {}
    }

    if (enableLoginServer)
    {
//      logStatusMessage(tr("Loading players database ..."));
        tcpPlayers = Player::loadPlayers();
    }

    // TCP server
    if (enableLoginServer)
    {
        logStatusMessage(tr("Starting TCP login server on port %1...").arg(loginPort));
        if (!tcpServer->listen(QHostAddress::Any,loginPort))
        {
            logStatusMessage(tr("TCP: Unable to start server on port %1 : %2").arg(loginPort).arg(tcpServer->errorString()));
            stopServer();
            return;
        }

        // If we use a remote login server, try to open a connection preventively.
        if (useRemoteLogin)
            remoteLoginSock.connectToHost(remoteLoginIP, remoteLoginPort);
    }

    // UDP server
    if (enableGameServer)
    {
        logStatusMessage(tr("Starting UDP game server on port %1...").arg(gamePort));
        if (!udpSocket->bind(gamePort, QUdpSocket::ReuseAddressHint|QUdpSocket::ShareAddress))
        {
            logStatusMessage(tr("UDP: Unable to start server on port %1").arg(gamePort));
            stopServer();
            return;
        }
    }

    if (enableGameServer)
    {
        // Start ping timeout timer
        pingTimer->start(pingCheckInterval);
    }

    if (enableMultiplayer)
        sync.startSync();

    if (enableLoginServer || enableGameServer)
        logStatusMessage(tr("Server started"));

    connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendCmdLine()));
    if (enableLoginServer)
        connect(tcpServer, SIGNAL(newConnection()), this, SLOT(tcpConnectClient()));
    if (enableGameServer)
    {
        connect(udpSocket, SIGNAL(readyRead()),this, SLOT(udpProcessPendingDatagrams()));
        connect(pingTimer, SIGNAL(timeout()), this, SLOT(checkPingTimeouts()));
    }
}
开发者ID:Dreyns,项目名称:LoE-PrivateServer,代码行数:101,代码来源:widget.cpp


示例5: client_contentReadyRead

		void client_contentReadyRead()
		{
			_content.append(_client->consumeContent());
			 emit readyRead();
			 //emit downloadProgress();
		}
开发者ID:knopkem,项目名称:pillow,代码行数:6,代码来源:HttpClient.cpp


示例6: qWarning

bool HttpClient::downloadFile( QString &urlIn, QString &destinationIn )
{
  // qDebug() << "HttpClient::downloadFile: url=" << urlIn << ", dest=" << destinationIn;

  if( downloadRunning == true )
    {
      qWarning( "HttpClient(%d): download is running!", __LINE__ );
      return false;
    }

  _url = urlIn;
  _destination = destinationIn;

  QUrl url( urlIn );
  QFileInfo fileInfo( destinationIn );

  if( urlIn.isEmpty() || ! url.isValid() || fileInfo.fileName().isEmpty() )
    {
      qWarning( "HttpClient(%d): Url or destination file are invalid!", __LINE__ );
      return false;
    }

  tmpFile = new QFile( destinationIn + "." +
                       QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss") );

  if( ! tmpFile->open( QIODevice::WriteOnly ) )
    {
      qWarning( "HttpClient(%d): Unable to open the file %s: %s",
                 __LINE__,
                 tmpFile->fileName ().toLatin1().data(),
                 tmpFile->errorString().toLatin1().data() );

      delete tmpFile;
      tmpFile = static_cast<QFile *> (0);
      return false;
    }

  // Check, if a proxy is defined in the configuration data. If true, we do use it.
  extern QSettings _settings;

  QString proxy = _settings.value( "/Internet/Proxy", "" ).toString();

  if( proxy.isEmpty() )
    {
      // Check the user's environment, if a proxy is defined there.
      char* proxyFromEnv = getenv("http_proxy");

      if( proxyFromEnv == 0 )
        {
          proxyFromEnv = getenv("HTTP_PROXY");
        }

      if( proxyFromEnv )
        {
          QString qProxy( proxyFromEnv );

          // remove an existing http prefix
          proxy = qProxy.remove("http://");
        }
    }

  if( ! proxy.isEmpty() )
    {
      QString hostName;
      quint16 port;

      if( parseProxy( proxy, hostName, port ) == true )
        {
          QNetworkProxy proxy;
          proxy.setType( QNetworkProxy::HttpProxy );
          proxy.setHostName( hostName );
          proxy.setPort( port );
          manager->setProxy( proxy );
        }
    }

  QNetworkRequest request;
  QString appl = QCoreApplication::applicationName() + "/" +
                 QCoreApplication::applicationVersion() +
                 " (Qt" + QT_VERSION_STR + "/X11)";

  request.setUrl( QUrl( _url, QUrl::TolerantMode ));
  request.setRawHeader( "User-Agent", appl.toLatin1() );

  reply = manager->get(request);

  if( ! reply )
    {
      qWarning( "HttpClient(%d): Reply object is invalid!", __LINE__ );
      return false;
    }

  reply->setReadBufferSize(0);

  connect( reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()) );

  connect( reply, SIGNAL(error(QNetworkReply::NetworkError)),
           this, SLOT(slotError(QNetworkReply::NetworkError)) );

  connect( reply, SIGNAL(finished()),
//.........这里部分代码省略.........
开发者ID:Exadios,项目名称:KFLog,代码行数:101,代码来源:httpclient.cpp


示例7: QTcpSocket

THttpSocket::THttpSocket(QObject *parent)
    : QTcpSocket(parent), lengthToRead(-1), lastProcessed(QDateTime::currentDateTime())
{
    T_TRACEFUNC("");
    connect(this, SIGNAL(readyRead()), this, SLOT(readRequest()));
}
开发者ID:feda12,项目名称:treefrog-framework,代码行数:6,代码来源:thttpsocket.cpp


示例8: QNetworkAccessManager

//! [0]
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
        this, SLOT(replyFinished(QNetworkReply*)));

manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));
//! [0]


//! [1]
QNetworkRequest request;
request.setUrl(QUrl("http://qt.nokia.com"));
request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");

QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
        this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
        this, SLOT(slotSslErrors(QList<QSslError>)));
//! [1]

//! [2]
QNetworkConfigurationManager manager;
networkAccessManager->setConfiguration(manager.defaultConfiguration());
//! [2]

//! [3]
networkAccessManager->setConfiguration(QNetworkConfiguration());
//! [3]
开发者ID:Afreeca,项目名称:qt,代码行数:30,代码来源:src_network_access_qnetworkaccessmanager.cpp


示例9: QTcpSocket

QgsHelpContextSocket::QgsHelpContextSocket( int socket, QObject *parent ) :
    QTcpSocket( parent )
{
  connect( this, SIGNAL( readyRead() ), SLOT( readClient() ) );
  setSocketDescriptor( socket );
}
开发者ID:CzendaZdenda,项目名称:qgis,代码行数:6,代码来源:qgshelpserver.cpp


示例10: syncFinished

void HttpPoll::http_result()
{
	// check for death :)
	QPointer<QObject> self = this;
	syncFinished();
	if(!self)
		return;

	// get id and packet
	QString id;
	QString cookie = d->http.getHeader("Set-Cookie");
	int n = cookie.indexOf("ID=");
	if(n == -1) {
		resetConnection();
		setError(ErrRead);
		return;
	}
	n += 3;
	int n2 = cookie.indexOf(';', n);
	if(n2 != -1)
		id = cookie.mid(n, n2-n);
	else
		id = cookie.mid(n);
	QByteArray block = d->http.body();

	// session error?
	if(id.right(2) == ":0") {
		if(id == "0:0" && d->state == 2) {
			resetConnection();
			connectionClosed();
			return;
		}
		else {
			resetConnection();
			setError(ErrRead);
			return;
		}
	}

	d->ident = id;
	bool justNowConnected = false;
	if(d->state == 1) {
		d->state = 2;
		justNowConnected = true;
	}

	// sync up again soon
	if(bytesToWrite() > 0 || !d->closing) {
		d->t->start(d->polltime * 1000);
  }

	// connecting
	if(justNowConnected) {
		connected();
	}
	else {
		if(!d->out.isEmpty()) {
			int x = d->out.size();
			d->out.resize(0);
			takeWrite(x);
			bytesWritten(x);
		}
	}

	if(!self)
		return;

	if(!block.isEmpty()) {
		appendRead(block);
		readyRead();
	}

	if(!self)
		return;

	if(bytesToWrite() > 0) {
		do_sync();
	}
	else {
		if(d->closing) {
			resetConnection();
			delayedCloseFinished();
			return;
		}
	}
}
开发者ID:ExtensionHealthcare,项目名称:iris,代码行数:86,代码来源:httppoll.cpp


示例11: QMainWindow


//.........这里部分代码省略.........
    ui->vcmcomboBox->addItem("80 seconds");
    ui->vcmcomboBox->addItem("100 seconds");

    ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
//    ui->customPlot->setBackground(Qt::transparent);
    ui->customPlot->legend->setVisible(true);
    ui->customPlot->legend->setFont(QFont("Helvetica", 7));
    ui->customPlot->axisRect()->setBackground(Qt::darkGray);
    ui->customPlot->axisRect()->setupFullAxesBox();

    ui->customPlot->addGraph(); // blue line
    ui->customPlot->graph(0)->setName("Encoder Count vs. Time");
    ui->customPlot->graph(0)->setPen(QPen(Qt::blue));
    ui->customPlot->graph(0)->setLineStyle(QCPGraph::lsLine);
    ui->customPlot->graph(0)->setAntialiasedFill(false);

    ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
    ui->customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
    ui->customPlot->xAxis->setAutoTickStep(true);
    ui->customPlot->xAxis->setTickStep(1);

    ui->customPlot_1->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);

    ui->customPlot_1->legend->setVisible(true);
    ui->customPlot_1->legend->setFont(QFont("Helvetica", 7));
    ui->customPlot_1->axisRect()->setBackground(Qt::darkGray);
    ui->customPlot_1->axisRect()->setupFullAxesBox();

    ui->customPlot_1->addGraph(); // blue line
    ui->customPlot_1->graph(0)->setName("Sensor Data vs. Time");
    ui->customPlot_1->graph(0)->setPen(QPen(Qt::green));
    ui->customPlot_1->graph(0)->setLineStyle(QCPGraph::lsLine);
    ui->customPlot_1->graph(0)->setAntialiasedFill(false);

    ui->customPlot_1->xAxis->setTickLabelType(QCPAxis::ltDateTime);
    ui->customPlot_1->xAxis->setDateTimeFormat("hh:mm:ss");
    ui->customPlot_1->xAxis->setAutoTickStep(true);

    foreach (QextPortInfo info, QextSerialEnumerator::getPorts())
    ui->portBox->addItem(info.portName);

    ui->portBox->setEditable(true);

    ui->baudRateBox->addItem("9600", BAUD9600);
    ui->baudRateBox->addItem("115200", BAUD115200);
    ui->baudRateBox->setCurrentIndex(2);

    ui->parityBox->addItem("NONE", PAR_NONE);
    ui->parityBox->addItem("ODD", PAR_ODD);
    ui->parityBox->addItem("EVEN", PAR_EVEN);

    ui->dataBitsBox->addItem("5", DATA_5);
    ui->dataBitsBox->addItem("6", DATA_6);
    ui->dataBitsBox->addItem("7", DATA_7);
    ui->dataBitsBox->addItem("8", DATA_8);
    ui->dataBitsBox->setCurrentIndex(3);

    ui->stopBitsBox->addItem("1", STOP_1);
    ui->stopBitsBox->addItem("2", STOP_2);

    ui->queryModeBox->addItem("POLLING", QextSerialPort::Polling);
    ui->queryModeBox->addItem("EVENT DRIVEN", QextSerialPort::EventDriven);

    timer = new QTimer(this);
    timer->setInterval(40);

    PortSettings settings = {BAUD115200, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 10};
    port = new QextSerialPort(ui->portBox->currentText(), settings, QextSerialPort::Polling);

    enumerator = new QextSerialEnumerator(this);
    enumerator->setUpNotifications();

    connect(ui->connect_Button, SIGNAL(clicked()), SLOT(run()));
    connect(ui->disconnect_Button, SIGNAL(clicked()), SLOT(disconnectClient()));
    connect(ui->stop_Button, SIGNAL(clicked()), SLOT(stopplot()));
    connect(ui->reset_window_Button, SIGNAL(clicked()), SLOT(resetfun()));
    connect(ui->enc_test_run_Button, SIGNAL(clicked()), SLOT(encoderfun()));
    connect(ui->enc_test_run_Button, SIGNAL(clicked()), SLOT(showdatadisp()));
    connect(ui->off_up_Button, SIGNAL(clicked()), SLOT(offloaderfun()));
    connect(ui->off_down_Button, SIGNAL(clicked()), SLOT(offloaderfun_1()));
    connect(ui->vcm_test_run_Button, SIGNAL(clicked()), SLOT(vcmfun()));
    connect(ui->vcm_test_run_Button, SIGNAL(clicked()), SLOT(showdatadisp()));
    connect(ui->reset_drive_board_Button, SIGNAL(clicked()), SLOT(resetdrivefun()));
    connect(ui->save_plot_Button, SIGNAL(clicked()), SLOT(saveplot_fun()));

    connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), SLOT(onBaudRateChanged(int)));
    connect(ui->parityBox, SIGNAL(currentIndexChanged(int)), SLOT(onParityChanged(int)));
    connect(ui->dataBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onDataBitsChanged(int)));
    connect(ui->stopBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onStopBitsChanged(int)));
    connect(ui->portBox, SIGNAL(editTextChanged(QString)), SLOT(onPortNameChanged(QString)));

    connect(ui->openCloseButton, SIGNAL(clicked()), SLOT(onOpenCloseButtonClicked()));
    connect(ui->sendButton, SIGNAL(clicked()), SLOT(onSendButtonClicked()));
    connect(ui->aboutButton, SIGNAL(clicked()), SLOT(about_fun()));

    connect(timer, SIGNAL(timeout()), SLOT(onReadyRead()));
    connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
    connect(enumerator, SIGNAL(deviceDiscovered(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
    connect(enumerator, SIGNAL(deviceRemoved(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
}
开发者ID:maharnab,项目名称:tactsof,代码行数:101,代码来源:mainwindow.cpp


示例12: QWidget

//#include <QDebug>
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    QTextCodec *utfcodec = QTextCodec::codecForName("UTF-8"); //qt4
    QTextCodec::setCodecForTr(utfcodec);
    QTextCodec::setCodecForCStrings(utfcodec);
    mySerialPort=new SerialPort(this);
    myTimer=new QTimer(this);
    connect(ui->toolButton, SIGNAL(clicked()), this, SLOT(refreshAvSerialPort()));
    connect(mySerialPort, SIGNAL(readyRead()), this , SLOT(readToPlainText()));
    //ui->groupBox->setHidden(ui->toolButton_3->isChecked());
    //ui->groupBox->hide();
    // fill data bits
    ui->comboBox_3->addItem(QLatin1String("8"), SerialPort::Data8);
    ui->comboBox_3->addItem(QLatin1String("7"), SerialPort::Data7);
    ui->comboBox_3->addItem(QLatin1String("6"), SerialPort::Data6);
    ui->comboBox_3->addItem(QLatin1String("5"), SerialPort::Data5);
    ui->comboBox_3->setCurrentIndex(0);

    // fill stop bits
    ui->comboBox_4->addItem(QLatin1String("2"), SerialPort::TwoStop);
#ifdef Q_OS_WIN
    ui->comboBox_4->addItem(QLatin1String("1.5"), SerialPort::OneAndHalfStop);
#endif
    ui->comboBox_4->addItem(QLatin1String("1"), SerialPort::OneStop);
    ui->comboBox_4->setCurrentIndex(ui->comboBox_4->count()-1);

    // fill parity
    ui->comboBox_5->addItem(QLatin1String("None"), SerialPort::NoParity);
    ui->comboBox_5->addItem(QLatin1String("Even"), SerialPort::EvenParity);
    ui->comboBox_5->addItem(QLatin1String("Odd"), SerialPort::OddParity);
    ui->comboBox_5->addItem(QLatin1String("Mark"), SerialPort::MarkParity);
    ui->comboBox_5->addItem(QLatin1String("Space"), SerialPort::SpaceParity);
    ui->comboBox_5->setCurrentIndex(0);

    // fill flow control
    ui->comboBox_6->addItem(QLatin1String("None"), SerialPort::NoFlowControl);
    ui->comboBox_6->addItem(QLatin1String("RTS/CTS"), SerialPort::HardwareControl);
    ui->comboBox_6->addItem(QLatin1String("XON/XOFF"), SerialPort::SoftwareControl);
    ui->comboBox_6->setCurrentIndex(0);
    refreshAvSerialPort();
    //currPortName="";
    loadSettings();
    if(complList.isEmpty())
        complList<<"ATID"<<"ATCH"<<"ATPL"<<"ATRE"<<"ATCN"<<"ATAC"<<"ATFR"<<"ATAD"<<"ATVR"<<"ATSH"<<"ATSL";

    myCompl=new QCompleter(complList, this);
    myCompl->setCaseSensitivity(Qt::CaseInsensitive);

    ui->lineEdit->setCompleter(myCompl);
    for(qint32 i=1; i<ui->comboBox_2->count(); i++) {
        if(ui->comboBox_2->itemText(i)==currPortName) {
            ui->comboBox_2->setCurrentIndex(i);
            break;
        }

    }
    dozvilNaOnovlPortiv=1;
    connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIndxToPushButton(int)));
    connect(ui->comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIndxToPushButton(int)));
    connect(ui->comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIndxToPushButton(int)));
    connect(ui->comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIndxToPushButton(int)));
    connect(ui->comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(changeIndxToPushButton(int)));

    connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_7, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->comboBox_8, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->cbTextSet, SIGNAL(currentIndexChanged(int)), this, SLOT(focusLineEdit(int)));
    connect(ui->toolButton_2,SIGNAL(clicked()), this , SLOT(focusLineEdit2()));
    connect(ui->toolButton_3,SIGNAL(clicked()), this , SLOT(focusLineEdit2()));
    connect(ui->toolButton_4,SIGNAL(clicked()), this , SLOT(focusLineEdit2()));

    connect(&checkPort, SIGNAL(portDisconnected()), this, SLOT(closeSerialPort()));

    //    onovlennyaTimer=new QTimer(this);
    //   connect(onovlennyaTimer, SIGNAL(timeout()), this, SLOT(onOnovlTimer()));
    //    onovlennyaTimer->start(1500);
}
开发者ID:HelloZB,项目名称:Qt_Terminal,代码行数:85,代码来源:widget.cpp


示例13: start


//.........这里部分代码省略.........
			if(mode == Worker::Stream && request.more && request.seq != 0)
			{
				log_warning("streamed input must start with seq 0");

				QMetaObject::invokeMethod(this, "respondError", Qt::QueuedConnection, Q_ARG(QByteArray, "bad-request"));
				return;
			}

			// fire and forget
			if(mode == Worker::Stream && toAddress.isEmpty())
				quiet = true;

			// can't use these two together
			if(mode == Worker::Single && request.more)
			{
				log_warning("cannot use streamed input on router interface");

				QMetaObject::invokeMethod(this, "respondError", Qt::QueuedConnection, Q_ARG(QByteArray, "bad-request"));
				return;
			}

			bodySent = false;

			inSeq = request.seq;

			if(!isAllowed(request.uri.host()) || (!request.connectHost.isEmpty() && !isAllowed(request.connectHost)))
			{
				QMetaObject::invokeMethod(this, "respondError", Qt::QueuedConnection, Q_ARG(QByteArray, "policy-violation"));
				return;
			}

			hreq = new HttpRequest(dns, this);
			connect(hreq, SIGNAL(nextAddress(const QHostAddress &)), SLOT(req_nextAddress(const QHostAddress &)));
			connect(hreq, SIGNAL(readyRead()), SLOT(req_readyRead()));
			connect(hreq, SIGNAL(bytesWritten(int)), SLOT(req_bytesWritten(int)));
			connect(hreq, SIGNAL(error()), SLOT(req_error()));
			maxResponseSize = request.maxSize;
			if(!request.connectHost.isEmpty())
				hreq->setConnectHost(request.connectHost);
			if(request.connectPort != -1)
				request.uri.setPort(request.connectPort);

			hreq->setIgnoreTlsErrors(request.ignoreTlsErrors);

			if(request.credits != -1)
				outCredits += request.credits;

			if(!headers.contains("Content-Length"))
			{
				if(request.more)
				{
					// ensure chunked encoding
					headers.removeAll("Transfer-Encoding");
					headers += HttpHeader("Transfer-Encoding", "chunked");
				}
				else
				{
					// ensure content-length
					if(!request.body.isEmpty() ||
						(request.method != "OPTIONS" &&
						request.method != "HEAD" &&
						request.method != "GET" &&
						request.method != "DELETE"))
					{
						headers += HttpHeader("Content-Length", QByteArray::number(request.body.size()));
					}
开发者ID:FriendsOfSpclOps,项目名称:zurl,代码行数:67,代码来源:worker.cpp


示例14: ReferenceCounter

MythSocket::MythSocket(
    qt_socket_fd_t socket, MythSocketCBs *cb, bool use_shared_thread) :
    ReferenceCounter(QString("MythSocket(%1)").arg(socket)),
    m_tcpSocket(new QTcpSocket()),
    m_thread(NULL),
    m_socketDescriptor(-1),
    m_peerPort(-1),
    m_callback(cb),
    m_useSharedThread(use_shared_thread),
    m_disableReadyReadCallback(false),
    m_connected(false),
    m_dataAvailable(0),
    m_isValidated(false),
    m_isAnnounced(false)
{
    LOG(VB_SOCKET, LOG_INFO, LOC + QString("MythSocket(%1, 0x%2) ctor")
        .arg(socket).arg((intptr_t)(cb),0,16));

    // Use direct connections so m_tcpSocket can be used
    // in the handlers safely since they will be running
    // in the same thread as all other m_tcpSocket users.

    connect(m_tcpSocket,  SIGNAL(connected()),
            this, SLOT(ConnectHandler()),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(ErrorHandler(QAbstractSocket::SocketError)),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(aboutToClose()),
            this, SLOT(AboutToCloseHandler()));
    connect(m_tcpSocket,  SIGNAL(disconnected()),
            this, SLOT(DisconnectHandler()),
            Qt::DirectConnection);
    connect(m_tcpSocket,  SIGNAL(readyRead()),
            this, SLOT(ReadyReadHandler()),
            Qt::DirectConnection);

    connect(this, SIGNAL(CallReadyRead()),
            this, SLOT(CallReadyReadHandler()),
            Qt::QueuedConnection);

    if (socket != -1)
    {
        m_tcpSocket->setSocketDescriptor(
            socket, QAbstractSocket::ConnectedState,
            QAbstractSocket::ReadWrite);

        ConnectHandler(); // already called implicitly above?
    }

    if (!use_shared_thread)
    {
        m_thread = new MThread(QString("MythSocketThread(%1)").arg(socket));
        m_thread->start();
    }
    else
    {
        QMutexLocker locker(&s_thread_lock);
        if (!s_thread)
        {
            s_thread = new MThread("SharedMythSocketThread");
            s_thread->start();
        }
        m_thread = s_thread;
        s_thread_cnt++;
    }

    m_tcpSocket->moveToThread(m_thread->qthread());
    moveToThread(m_thread->qthread());
}
开发者ID:ChristopherNeufeld,项目名称:mythtv,代码行数:70,代码来源:mythsocket.cpp


示例15: QDialog

MainWindow::MainWindow(Configuration *config, QWidget *parent)
    : QDialog(parent)
{
    QProcess::execute("mkdir -p cap");
    setWindowTitle("TTY Proxy Capture");
    setWindowIcon(QIcon(":/images/heart.svg"));

    createActions();
    createTrayIcon();
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
             this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    this->config = config;

    QStringList iplist = config->getHostAddress().split(".");

    QLabel *ipAddrLabel = new QLabel("Server IP:");
    ipAddr0 = new QSpinBox(this);
    ipAddr0->setRange(127, 254);
    ipAddr0->setValue(iplist[0].toInt());
    ipAddr1 = new QSpinBox(this);
    ipAddr1->setRange(0, 254);
    ipAddr1->setValue(iplist[1].toInt());
    ipAddr2 = new QSpinBox(this);
    ipAddr2->setRange(0, 254);
    ipAddr2->setValue(iplist[2].toInt());
    ipAddr3 = new QSpinBox(this);
    ipAddr3->setRange(220, 250);
    ipAddr3->setValue(iplist[3].toInt());

    QHBoxLayout *ipAddrLayout = new QHBoxLayout();
    ipAddrLayout->setSpacing(0);
    ipAddrLayout->addWidget(ipAddr0);
    ipAddrLayout->addWidget(ipAddr1);
    ipAddrLayout->addWidget(ipAddr2);
    ipAddrLayout->addWidget(ipAddr3);

    serverStatus = false;
    setIcon(serverStatus);
    switchButton = new QPushButton("Start", this);
    switchButton->setFocus(Qt::OtherFocusReason);
    connect(switchButton, SIGNAL(clicked()), this, SLOT(save()));
    // connect(switchButton, SIGNAL(clicked()), this, SLOT(start()));
    // connect(switchButton, SIGNAL(clicked()), this, SLOT(stop()));

    txBytes = 0;
    QLabel *txCountLabel = new QLabel("TX:");
    txCount = new QLineEdit;
    txCount->setAlignment(Qt::AlignRight);
    txCount->setReadOnly(true);
    txTcpSocket = new QTcpSocket(this);
    txDecode = new DecodeChannel("cap/tx%1.dat");
    connect(txTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
             this, SLOT(displayError(QAbstractSocket::SocketError)));
    connect(txTcpSocket, SIGNAL(connected()), this, SLOT(connectedChannel()));
    connect(txTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnectedChannel()));
    connect(txTcpSocket, SIGNAL(readyRead()), this, SLOT(readTxChannel()));
    
    rxBytes = 0;
    QLabel *rxCountLabel = new QLabel("RX:");
    rxCount = new QLineEdit;
    rxCount->setAlignment(Qt::AlignRight);
    rxCount->setReadOnly(true);
    rxTcpSocket = new QTcpSocket(this);
    rxDecode = new DecodeChannel("cap/rx%1.dat");
    connect(rxTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
             this, SLOT(displayError(QAbstractSocket::SocketError)));
    connect(rxTcpSocket, SIGNAL(connected()), this, SLOT(connectedChannel()));
    connect(rxTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnectedChannel()));
    connect(rxTcpSocket, SIGNAL(readyRead()), this, SLOT(readRxChannel()));

    QTimer *timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(refreshCount()));
	timer->start(500);

    statusBar = new QStatusBar;
    statusBar->showMessage("TTY Proxy Capture is ready ...");

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(ipAddrLabel, 0, 0);
    mainLayout->addLayout(ipAddrLayout, 0, 1, 1, 2);
    mainLayout->addWidget(switchButton, 0, 3);

    mainLayout->addWidget(txCountLabel, 1, 0);
    mainLayout->addWidget(txCount, 1, 1, 1, 2);

    mainLayout->addWidget(rxCountLabel, 2, 0);
    mainLayout->addWidget(rxCount, 2, 1, 1, 2);

    mainLayout->addWidget(statusBar, 3, 0, 1, 4);

    setLayout(mainLayout);

    trayIcon->show();
}
开发者ID:bxxbht,项目名称:Github,代码行数:95,代码来源:mainwindow.cpp


示例16: readyRead

void DClusterUserHasDevicesListPage::on_recvDataFromOtherPage(quint16 cmdCode, char *data, quint16 dataLen)
{
    emit readyRead(cmdCode, data, dataLen);
}
开发者ID:LinLinYi,项目名称:kirogi,代码行数:4,代码来源:DClusterUserHasDevicesListPage.cpp


示例17: Fragment

void ZTPManager::procPkg(const QByteArray &recvBuff,const QString &remoteHost,quint16 remotePort)
{
    Fragment* fragment = new Fragment(recvBuff);
    if(!fragment->isValid())
    {
        fragment->print();
        return;
    }
    FragmentList* fragMentList = NULL;

//    qDebug()<<"fragment :"<<fragment->identifier<<" "<<fragment->checksum<<" "<<fragment->fragment_count<<" "<<fragment->fragment_offset<<" "<<fragment->len;
//    qDebug()<<"fragment isvalid:"<<fragment->isValid();
    if(!workMap.contains(fragment->identifier) || workMap[fragment->identifier] == NULL)
    {
        fragMentList = new FragmentList(fragment->identifier);
        connect(fragMentList,SIGNAL(timeout(quint16)),this,SLOT(onTimeout(quint16)));
        workMap.insert(fragment->identifier,fragMentList);
    }
    else
    {
        fragMentList =  workMap[fragment->identifier];
    }
    if(fragMentList == NULL)
    {
        return;
    }
//    workMap[fragment->identifier]->timer.start(_timeout);  //内存泄漏隐患
    fragMentList->fragment_list.append(fragment);
    if(fragMentList->fragment_list.length() == fragment->fragment_count)
    {
        qSort(fragMentList->fragment_list.begin(),fragMentList->fragment_list.end(),lessThan);
        QByteArray recvBuff;
        for(int i = 0; i < fragment->fragment_count;i++)
        {
            recvBuff.append(fragMentList->fragment_list[i]->data);
        }
        FragmentList* node = fragMentList;
        workMap.remove(fragment->identifier);
//        node->timer.stop();//内存泄漏隐患
        delete node;        // ZZZZZZZZZZZZZZZZZZZZZZZ
        qint64 len;
        memcpy(&len,recvBuff.data()+6,8);
        if(recvBuff.length()!=len)
        {
            qDebug("recv ZTP data error: has data %lld bytes and actually recv %d bytes!!\n",
                len,recvBuff.length());
        }
        ZTPprotocol* ztp = new ZTPprotocol(recvBuff);
        ztp->addPara("RemoteHost",remoteHost);
        ztp->addPara("RemotePort",QString::number(remotePort));

        ztpListMutex.lock();
        if(ztpList.length()>=500)
        {
            delete ztp;
            ztpListMutex.unlock();
            return;
        }
        ztpList.append(ztp);
        ztpListMutex.unlock();
        emit readyRead();
    }
}
开发者ID:zhangxuran11,项目名称:RoomMedia,代码行数:63,代码来源:ztpmanager.cpp


示例18: QUdpSocket

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ readyReadStandardError函数代码示例发布时间:2022-05-30
下一篇:
C++ ready函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap