Results 1 to 5 of 5

Thread: Getting X-errors during runtime while drawing rectangles on qwidget

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Getting X-errors during runtime while drawing rectangles on qwidget

    Hello,
    My application is an MDI and on one of the child windows, i need to draw 1500 rectangles to depict the overall status of the system. The drawing is been done on a jpeg image. The drawing is done fine, but as i go on opening and closing the child windows one by one i get the following X-errors while the app is running :

    X Error: BadGC (invalid GC parameter) 13
    Major opcode: 66
    Minor opcode: 0
    Resource id: 0x2e0043c
    X Error: BadGC (invalid GC parameter) 13
    Major opcode: 66
    Minor opcode: 0
    Resource id: 0x2e0043c
    X Error: BadGC (invalid GC parameter) 13
    Major opcode: 66
    Minor opcode: 0
    Resource id: 0x2e0043c..........

    My paintevent code is as below :

    void CascadeOverview:aintEvent(QPaintEvent *)
    {
    static int X1,Y1,X2,Y2;
    Y1 = 5;
    Y2 = 10;
    QImage cascadeBG("./images/cascadebackground.png"); // jpeg image
    QPixmap bufferCascadeBG(cascadeBG);

    if (paintActualArea->isActive())
    paintActualArea->end();

    if (paintBufferArea->isActive())
    paintBufferArea->end();

    paintActualArea->begin(pixmapBackground);
    paintBufferArea->begin(&bufferCascadeBG);

    paintActualArea->setBrush(green);
    paintBufferArea->setBrush(green);

    for( int i=0;i<1500;i++)
    {

    paintActualArea->drawRect(X1,Y1,5,10);
    paintBufferArea->drawRect(X1,Y1,5,10);

    X1= X1+25;
    X2 = X2+25;
    if(X1>1250)
    {
    X1=0;
    Y1 = Y1+10;
    Y2 = Y2+10;
    }
    if(X2>1250)
    {
    X2=0;
    Y1 = Y1+10;
    Y2 = Y2+10;
    }

    }
    bitBlt (pixmapBackground, 0, 0, &bufferCascadeBG);

    paintBufferArea->end();
    paintActualArea->end();


    }


    should i detach the image once painter is ended or is there any specific means to release the graphic objects in qt(like GDI in windows)

    Thanks for help in advance,
    Anitha.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting X-errors during runtime while drawing rectangles on qwidget

    It looks like that Y1 variable goes up to 15000.

    Qt docs say:
    Warning: Note that QPainter does not attempt to work around coordinate limitations in the underlying window system. Some platforms may behave incorrectly with coordinates as small as +/-4000.
    Maybe that's the problem?

  3. #3
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Getting X-errors during runtime while drawing rectangles on qwidget

    I have tried drawing less number of rectangles, but i still get the errors The errors occur very randomly, so should i follow any work around to free the memory or something like that. Please do reply.

    Anitha

  4. #4
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Getting X-errors during runtime while drawing rectangles on qwidget

    May be you should try to create QPainter's in the paintEvent() like this:


    Qt Code:
    1. void CascadeOverview:paintEvent(QPaintEvent *)
    2. {
    3. static int X1,Y1,X2,Y2;
    4. Y1 = 5;
    5. Y2 = 10;
    6.  
    7. QImage cascadeBG("./images/cascadebackground.png");
    8. QPixmap bufferCascadeBG(cascadeBG);
    9.  
    10. QPainter paintActualArea(pixmapBackground);
    11. QPainter paintBufferArea(&bufferCascadeBG);
    12.  
    13. paintActualArea.setBrush(green);
    14. paintBufferArea.setBrush(green);
    15.  
    16. for( int i=0;i<1500;i++)
    17. {
    18. paintActualArea.drawRect(X1,Y1,5,10);
    19. paintBufferArea.drawRect(X1,Y1,5,10);
    20.  
    21. X1= X1+25;
    22. X2 = X2+25;
    23. if(X1>1250)
    24. {
    25. X1=0;
    26. Y1 = Y1+10;
    27. Y2 = Y2+10;
    28. }
    29.  
    30. if(X2>1250)
    31. {
    32. X2=0;
    33. Y1 = Y1+10;
    34. Y2 = Y2+10;
    35. }
    36. }
    37.  
    38. bitBlt(pixmapBackground, 0, 0, &bufferCascadeBG);
    39. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Getting X-errors during runtime while drawing rectangles on qwidget

    I have tried drawing less number of rectangles,
    What jacek pointed out is still true.
    The problem is not the number of rectangles, but the value of Y1!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.