Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt creator (mask a variable)
Forum Updated to NodeBB v4.3 + New Features

Qt creator (mask a variable)

Scheduled Pinned Locked Moved Qt Creator and other tools
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zirtek
    wrote on 26 Feb 2015, 07:50 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Feb 2015, 09:38 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      26 Feb 2015, 07:50

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved