Qt creator (mask a variable)



  • Hello

    I make a project for my school, I need to comminucate with USB and write/read some informations.

    usually live I use C language and I make mask easily. I need just make a mask with my variable dataL.

    my program is
    @
    void MainWindow::on_pushButton_clicked()
    {

    if(flag == 0)
    {
        ui->pushButton->setText("Activé");
        ui->pushButton->setToolTip("désactivé ?");
        ui->pushButton->setStyleSheet("* { background-color: rgb(125,255,100) }");
        flag = 1;
        QByteArray dataL = serial->readAll();
        dataL = (dataL | 0b1000);
        serial->write(dataL);
    }
    else
    {
        ui->pushButton->setText("Désactivé");
        ui->pushButton->setToolTip("activé ?");
        ui->pushButton->setStyleSheet("* { background-color: rgb(255,125,100) }");
        flag = 0;
        serial->write("0000");
    }
    

    }@

    When I compile the line 11 say : QByteArray::operator QNoImplicitBoolCast() const' is private

    if someone can help me.

    Zirtek


  • Lifetime Qt Champion

    Hi,

    QByteArray is not a byte so you can't just mask it like that. You first need to extract the values you want to mask.

    In any case, you're not using QSerialPort correctly. readAll() will only give you something if you have data available. You should rather take a look at the terminal example to see how it works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.