Important: Please read the Qt Code of Conduct -

How to Send and Receive data from Different files

  • Hello All,

    I am new to the Qt/QML, i am getting the value from mainwindow.cpp and i have function or file( i don't know, shall i make it in function or file below code for brightness please suggest me) for reduce the brightness of display i.e
    /* code for brightness /
    QFile f("/sys/class/backlight/mi-bl/brightness"); | QIODevice::Truncate | QIODevice::Text);
    f.write("200"); // it is change at runtime
    ********************* */
    and i am getting the data from serial port i.e,

    void SerialPortReader::handleReadyRead()
    QByteArray data;
    QString str;
    data = m_serialPort->readAll();
    str = data;

    i want to send a parameter str to f.write(*** ); and data is change frequently at runtime how do this task, please any one have solution please guide me,

    Best Regards,
    Nandish sg

  • Hi @nandishsg

    Maybe you are looking for SIGNAL/SLOT, just after str = data;

    emit backlightValueReceived(str);//send str value

    and then on your MainWindow.cpp you need to have a slot:

    onBacklightValueReceived(const str  &backlightValue)

    But best way would be to have a class : Backlight, and to have writeValue(str) called just after str = data, instead of having everything in mainWindow;

    I hope this can help you

Log in to reply