Qt graphicsView error signal



  • Hi guys,

    I am trying to draw something on graphicsView, but there are some error signal shows up, it's like:

    qt error signal

    I use Arduino to run the process, the code is like:

    while(y <= 5){
    
           for (float x = voltx; x <= 4.96; x += 0.01){
           Serial.print("y = ");
           Serial.println(y*102.4);
           Serial.print("x = ");
           Serial.println(x*102.4);
           analogWrite(XPin, x * 51.49);
           delay(100);
    
           
           }
           
           y += 0.05;
           Serial.print("y = ");
           Serial.println(y*102.4);
           analogWrite(YPin, y * 51.49);
          
    
           for (float x = 4.95; x >= voltx - 0.01; x -= 0.01){
           Serial.print("y = ");
           Serial.println(y*102.4);
           Serial.print("x = ");
           Serial.println(x*102.4);
           analogWrite(XPin, x * 51.49);
           delay(100);
      
         }
    
           y += 0.05;
           Serial.print("y = ");
           Serial.println(y*102.4);
           analogWrite(YPin, y * 51.49);
          
    

    Input the voltage from 0 to 4.96 volt and transfer it to pixels, but the error signal occur in the region I didn't set for scanning. How is it happened?

    Qt code:

    void MainWindow::updateP(){
        if(!open) return;
    
        QTextStream stream(arduino);
        QString line;
        while(stream.readLineInto(&line)){
            QRegularExpression re("([x,y,p,a,b]) = ([0-9]{1,4})");
            QRegularExpressionMatchIterator i=re.globalMatch(line);
            while(i.hasNext()){
                QRegularExpressionMatch match=i.next();
                if(!match.hasMatch()){
                    qDebug() << "No match!";
                    continue;
                }
                QString xoryorporaorb=match.captured(1);
                QString matched=match.captured(2);
    
                bool ok=false;
                if(xoryorporaorb=="x") x=matched.toFloat(&ok);
                else if(xoryorporaorb=="y") y=matched.toFloat(&ok);
                else if(xoryorporaorb=="p") p=matched.toFloat(&ok);
                else if(xoryorporaorb=="a") a=matched.toFloat(&ok);
                else if(xoryorporaorb=="b") b=matched.toFloat(&ok);
                else continue;
                if(!ok){
                    qDebug() << "Could not convert \"" << matched <<"\" to an integer!";
                    continue;
                }
    
                QBrush whiteBrush(Qt::white);
                QPen whitePen(Qt::white, 1.);
                scene->addEllipse(a, b, 5, 5, whitePen, whiteBrush);
    

    Please give me some suggestion kindly, thanks!

    p.s Funny thing is, this error didn't happen if I use mega2560, it's about the processing time?


  • Moderators

    @Macive-Xiong What is the error? I only see garbage in the link you posted.



  • Hi @jsulm
    yes, that's what I meant, in the link I posted is the picture I took, the error signal is the points in the circle, I didn't input the position there but somehow it showed up. Any suggestion?


  • Moderators

    @Macive-Xiong I still don't understand: what do you mean by "error signal"?



  • @jsulm

    OK!! From the photo in that link, you can see a bunch of lines in the right of the pic. That's the right position I would like to set the points on. But in the up and left of the pic I circled , you can see some points and lines which are not what I want. I didn't set the points on those positions which is I think it's a error signal. I am not sure if this is a right reference for that but since I don't need those points, but it showed... Any suggestion?

    Btw, I am thinking about grayscale, is it possible that I could do some grayscale in my QGraphicsView, instead of setting points?

    Thank you so much:)


  • Moderators

    @Macive-Xiong Well, if there are points then you most probably put them there. You should check all the coordinates you're getting (a/b) - you can print them via qDebug() << a << b;


Log in to reply
 

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