Qt World Summit: Register Today!

sending data over serial port

  • hi....i want to send data over serial port to microcontroller....below is my code and im getting errors...so plz can anyone help
    void MainWindow::on_btStatus_released() {
    if ( m_serialPort->isOpen()) {
    AddStatus("Comport open. ");
    } else {
    AddStatus("Comport not open. ");
    QStringList text = "a";



    1. error: C2440: 'initializing' : cannot convert from 'const char [2]' to 'QStringList'
      Constructor for class 'QStringList' is declared 'explicit'
    2. error: C2039: 'toStdString' : is not a member of 'QStringList'
      3)error: C2228: left of '.c_str' must have class/struct/union

  • Lifetime Qt Champion


    1. QStringList is a list of strings not a string. You should do QString text = ...
    2. When you fixed 1 then 2 will work

  • Lifetime Qt Champion


    Error 1: you are trying to assign a string in a QStringList, did you want QString ?
    Error 2: Like written QStringList doesn't have such a method but QString does.
    Error 3: Comes from error 2, you are trying to call a function over a result you don't have.

    Note that QSerialPort::write has an overload that takes a QByteArray so it's useless to do all these conversions

    QByteArray data("a");

  • This post is deleted!

Log in to reply