Nominate our 2022 Qt Champions!

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->setToolTip("désactivé ?");
        ui->pushButton->setStyleSheet("* { background-color: rgb(125,255,100) }");
        flag = 1;
        QByteArray dataL = serial->readAll();
        dataL = (dataL | 0b1000);
        ui->pushButton->setToolTip("activé ?");
        ui->pushButton->setStyleSheet("* { background-color: rgb(255,125,100) }");
        flag = 0;


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

    if someone can help me.


  • Lifetime Qt Champion


    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