Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt + in porting + i got error QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1
Forum Updated to NodeBB v4.3 + New Features

Qt + in porting + i got error QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 9.7k 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.
  • S Offline
    S Offline
    sushmars
    wrote on last edited by
    #1

    hi,
    In my code i use to draw a real time graph outside paintEvent by setting property WA_PaintOutsidePaintEvent to true for qframe. It is plotting properly in my linux desktop as it is having x11. when i ran the same app in my arm based processor for which we have ported qt, i am getting error
    QWidget::paintEngine: Should no longer be called
    QPainter::begin: Paint device returned engine == 0, type: 1

    As my arm environment is not having x11,Is this is the problem to draw outside paint event.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      Well: don't do that. Paint on a QImage / QPixmap buffer and schedule a repaint, then just blit the buffer.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sushmars
        wrote on last edited by
        #3

        Then i need to use paintEvent function because repaint / update will call paintEvent function.
        Any other solution to draw outside paintEvent function because in my application there are 15 different graphs. some page will display 4 graphs at a time on a same gui-page depending on real time value.

        Thanks for reply

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          Yes, but the paintEvent will be easy to code (just blit the buffer you prepared, i.e.

          @
          QPainter p(this);
          p.drawPixmap(buffer);
          @

          . And in the other places where you used to paint directly on the widget, just open the painter on that buffer instead. I know it's a hack, but painting outside paint events is definitely something you shouldn't do in the first place.

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Hi sushmars,

            if you are not using X11, which painting system do you use? Qt embedded with framebuffer? then perhaps a "QDirectPainter":http://doc.qt.nokia.com/latest/qdirectpainter.html could help, as you xcan access the framebuffer also outside the paint event. But then you loos Qt's double buffer features...

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sushmars
              wrote on last edited by
              #6

              Here is a piece of code which displays 2 graphs at a time Which is called by 2 threads simultaneously.

              @
              QPainter *Dys_ecgpainter;
              QPainter *Dys_Balpainter;
              @

              in init function i declare those 2 painters

              @
              {
              Dys_ecgpainter= new QPainter;
              ansiscopeMainWindow->ui->DysAutonomia_Test_ECG_frame->setAttribute(Qt::WA_PaintOutsidePaintEvent,true);
              Dys_ecgpainter->begin((QWidget*)ansiscopeMainWindow->ui->DysAutonomia_Test_ECG_frame);
              Dys_ecgpainter->drawRect(0,0,235,80);

              Dys_Balpainter = new QPainter;
              ansiscopeMainWindow->ui->DysAutonomia_Test_balANS_frame->setAttribute(Qt::WA_PaintOutsidePaintEvent,true);
              Dys_Balpainter->begin( (QWidget*)ansiscopeMainWindow->ui->DysAutonomia_Test_balANS_frame);
              Dys_Balpainter->drawRect(0,0,235,80);

              }
              @

              Dys_DrawECG function is called from ECG thread which plots ecg on a qframe

              @
              void Dys_DrawECG(int data)
              {
              Dys_ecgpainter->drawLine(Dys_ECGgraph.lastplot.X,Dys_ECGgraph.lastplot.Y,Dys_ECGgraph.currentplot.X,Dys_ECGgraph.currentplot.Y);

              if(Dys_ECGgraph.currentplot.X >= Dys_ECGgraph.rightbottom.X)
              {
                  Dys_ECGgraph.currentplot.X = 0;
                  Dys_ecgpainter->fillRect(0,0,235,80,Qt::white);
                  //qWarning("\nAfter reaching end of frame 200\n");
              
              }
              
              Dys_ECGgraph.lastplot.X=Dys_ECGgraph.currentplot.X;
              Dys_ECGgraph.lastplot.Y=Dys_ECGgraph.currentplot.Y;
              

              }
              @

              Dys_DrawbalANS function is called from BalANS thread which plots balANS on a qframe

              @
              void Dys_DrawbalANS(POINT *Dys_points)
              {

              int i;
              int firsttime=1;
              
              float x,y;
              int Xvalue ,Yvalue ;
              int Xpos, Ypos;
              int balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY;
              balCurrentPlotX = 0;
              balCurrentPlotY = 0;
              balLastPlotX = 0;
              balLastPlotY = 0;
              
              
              
              
               Dys_Balpainter->fillRect(0,0,235,80,Qt::white);
               Dys_Balpainter->drawLine(117,0,117,20);
               Dys_Balpainter->drawLine(60,0,60,10);
               Dys_Balpainter->drawLine(174,0,174,10);
              
               Dys_Balpainter->drawLine(0,40,20,40);
               Dys_Balpainter->drawLine(0,20,10,20);
               Dys_Balpainter->drawLine(0,60,10,60);
              
              firsttime =1;
              for(i = 0; i< 312; i++)
              {
              
                  
              
                  if(firsttime)
                  {
                      firsttime=0;
                      // Balpainter->moveTo(Xpos,Ypos);  //Pen Position
                      Dys_Balpainter->drawPoint(balCurrentPlotX,balCurrentPlotX);
              
                  }
                  else
                  {   Dys_Balpainter->drawLine(balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY);
                  }
                  
                  balLastPlotX = balCurrentPlotX;
                  balLastPlotY = balCurrentPlotY;
              }
              

              }
              @

              EDIT: please use @-tags for code highlighting, Gerolf

              1 Reply Last reply
              0

              • Login

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