当前位置: 首页>>代码示例>>C++>>正文


C++ QSerialPort::flowControl方法代码示例

本文整理汇总了C++中QSerialPort::flowControl方法的典型用法代码示例。如果您正苦于以下问题:C++ QSerialPort::flowControl方法的具体用法?C++ QSerialPort::flowControl怎么用?C++ QSerialPort::flowControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSerialPort的用法示例。


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

示例1: getPortSettings

PortSettings PositioningMethodSerialPortOptions::getPortSettings(const QString &APortName)
{
    PortSettings portSettings;
    OptionsNode node;
    if (Options::hasNode(OPV_POSITIONING_METHOD_SERIALPORT, APortName))
        node = Options::node(OPV_POSITIONING_METHOD_SERIALPORT, APortName);
    else
    {
        QSerialPort *serialPort = new QSerialPort(APortName);
        if (serialPort->open(QIODevice::ReadOnly))
        {
            portSettings.FBaudRate    = serialPort->baudRate();
            portSettings.FDataBits    = serialPort->dataBits();
            portSettings.FStopBits    = serialPort->stopBits();
            portSettings.FParity      = serialPort->parity();
            portSettings.FFlowControl = serialPort->flowControl();
            serialPort->close();
        }
        else // Failed to open the port
            node = Options::node(OPV_POSITIONING_METHOD_SERIALPORT, APortName);
        serialPort->deleteLater();
    }
    if (!node.isNull())
    {
        portSettings.FBaudRate = node.value("baud-rate").toLongLong();
        portSettings.FDataBits = (QSerialPort::DataBits)node.value("data-bits").toInt();
        portSettings.FStopBits = (QSerialPort::StopBits)node.value("stop-bits").toInt();
        portSettings.FParity = (QSerialPort::Parity)node.value("parity").toInt();
        portSettings.FFlowControl = (QSerialPort::FlowControl)node.value("flow-control").toInt();
    }
    return portSettings;
}
开发者ID:RoadWorksSoftware,项目名称:eyecu-qt,代码行数:32,代码来源:positioningmethodserialportoptions.cpp

示例2: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    qRegisterMetaType<eegDataType::iterator>("eegDataType::iterator");


    /// server
    ui->serverPortSpinBox->setMaximum(65535);
    int hostCounter = 0;
    ui->serverAddressComboBox->addItem("local, 120");
    ui->serverAddressComboBox->setItemData(hostCounter++,
                                           QVariant("127.0.0.1:120"));

    ui->serverAddressComboBox->addItem("local, home");
    ui->serverAddressComboBox->setItemData(hostCounter++,
                                           QVariant("127.0.0.1:35577"));

    ui->serverAddressComboBox->addItem("Enceph");
    ui->serverAddressComboBox->setItemData(hostCounter++,
                                           QVariant("213.145.47.104:120"));

    ui->serverAddressComboBox->addItem("pew");
    ui->serverAddressComboBox->setItemData(hostCounter++,
                                           QVariant("192.168.0.104:120"));
    connect(ui->serverAddressComboBox, SIGNAL(highlighted(int)),
            this, SLOT(serverAddressSlot(int)));
    connect(ui->serverAddressComboBox, SIGNAL(currentIndexChanged(int)),
            this, SLOT(serverAddressSlot(int)));
#if MY_LINROWS
    ui->serverAddressComboBox->setCurrentText("pew");
#else
    ui->serverAddressComboBox->setCurrentText("Enceph");
#endif


//    ui->serverAddressComboBox->setCurrentText("pew"); /// fix via router, always 192.168.0.104


    /// com
    for(int i = 0; i < 9; ++i)
    {
        ui->comPortComboBox->addItem("COM"+QString::number(i+1));
    }
    ui->comPortComboBox->setCurrentText("COM5");

#if COM_IN_MAIN
    connect(ui->connectComPortPushButton, SIGNAL(clicked()),
            this, SLOT(comPortSlot()));

    comPort = new QSerialPort(this);
    connect(comPort, SIGNAL(error(QSerialPort::SerialPortError)),
            this, SLOT(serialPortErrorSlot(QSerialPort::SerialPortError)));
    connect(this->ui->comPortSendOnePushButton, SIGNAL(clicked()),
            this, SLOT(sendOne()));
    connect(this->ui->comPortSendTwoPushButton, SIGNAL(clicked()),
            this, SLOT(sendTwo()));
#endif



#if 0
    /// COM test
    QSerialPort * comPort;
    comPort = new QSerialPort(this);

    comPort->setPortName(ui->comPortComboBox->currentText());
    comPort->open(QIODevice::WriteOnly);

    if(comPort->isOpen())
    {
//        cout << comPort->errorString() << endl;
        cout << "serialPort opened: " + def::comPortName << endl;
        cout << "portName: " << comPort->portName().toStdString() << endl;
        cout << "dataBits: " << comPort->dataBits() << endl;
        cout << "baudRate: " << comPort->baudRate() << endl;
        cout << "dataTerminalReady: " << comPort->isDataTerminalReady() << endl;
        cout << "flowControl: " << comPort->flowControl() << endl;
        cout << "requestToSend: " << comPort->isRequestToSend() << endl;
        cout << "stopBits: " << comPort->stopBits() << endl << endl;
    }

    comPortDataStream.setDevice(comPort);
#endif



    /// socket
#if SOCKET_IN_MAIN
    socket = new QTcpSocket(this);
#endif

#if !DATA_READER
    socketDataStream.setDevice(socket);
    socketDataStream.setByteOrder(QDataStream::LittleEndian); // least significant bytes first
#endif

#if SOCKET_IN_MAIN
//.........这里部分代码省略.........
开发者ID:ArtfulVampire,项目名称:TcpClient,代码行数:101,代码来源:mainwindow.cpp


注:本文中的QSerialPort::flowControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。