Results 1 to 3 of 3

Thread: painter problem in new Qt-4.2.3 installation

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default painter problem in new Qt-4.2.3 installation

    Hi all

    I just installed Kubuntu to 7.04 on two of my computers. On both I downloaded Qt from A Trolltech mirror.

    All went fine, no errors or messages on installation

    I have 2 programs that use "QPaintEvent". Both work fine on another computer running the same Qt version. Now one program runs fine on the new installations, the othe locks up the computer and forces a re-boot on both of the new installations.

    This works fine on all computers
    Qt Code:
    1. void BaseForm::paintEvent(QPaintEvent * )
    2. {
    3.  
    4. int xs, xe, ys, ye;
    5. int W, H, w, h;
    6. int width, height;
    7. int counter;
    8. QPainter p( this );
    9. QPen pen;
    10. QFont f;
    11.  
    12. if(addressList.count() == 0) return;
    13. f.setFamily("MuktiNarrow");
    14. f.setPointSize(10);
    15. p.setFont(f);
    16. pen.setBrush(Qt::black);
    17. p.setPen(pen);
    18. W = ui.frmLabelBoxes->width();
    19. H = ui.frmLabelBoxes->height();
    20.  
    21. width = ((W-20)-30)/3;
    22. height = (H - 115)/10;
    23. counter = 0;
    24. for(h = 0; h < 10; ++h)
    25. {
    26. for(w = 0; w < 3; ++w)
    27. {
    28.  
    29. k = addressList[counter++];
    30. if(counter > addressList.count()-1) return;
    31. xs = 35 + w * (10 + width);
    32. ys = 30 + h * (10 + height);
    33. xe = width;
    34. ye = height;
    35. p.drawRect(xs, ys, xe, ye );
    36. p.fillRect(xs+1, ys+1, xe-1, ye-1, Qt::white);
    37. k = addressList[counter++];
    38. temp = k.split("\n");
    39. count = temp.count();
    40. for(n = 0; n < count; ++n)
    41. p.drawText(xs + 10, ys + 15 * (n + 1) , temp[n]);
    42. }
    43. }
    To copy to clipboard, switch view to plain text mode 
    And this llocks up on the "drawLine" and the "drawText" commands (they are optioned out here)
    Qt Code:
    1. void dlgMain::paintEvent(QPaintEvent * /*event*/)
    2. {
    3. QString k, h;
    4. double angle;
    5. int n, xs, xe, ys, ye, xc, yc;
    6. bool ok;
    7. QPainter p( this );
    8. QPen pen;
    9. QFont f;
    10.  
    11. if(paintSupportLines.count () > 0)
    12. {
    13. f.setFamily("Courier");
    14. f.setPointSize(dwgScaleFactor);
    15. p.setFont(f);
    16. pen.setBrush(Qt::blue);
    17. p.setPen(pen);
    18. p.setViewport(viewportRect);
    19. p.setWindow(windowRect);
    20.  
    21. if(clearWindow == "erase")
    22. {
    23. p.eraseRect(windowRect);
    24. clearWindow = "cancel erase";
    25. }
    26. else
    27. {
    28. for( n = 0; n < paintSupportLines.count(); ++n )
    29. {
    30. p.setClipRect(clippingRect);
    31. k = paintSupportLines[n];
    32. temp = k.split( "," );
    33.  
    34. xs = temp[0].toInt(&ok);
    35. ys = temp[1].toInt(&ok);
    36. xe = temp[2].toInt(&ok);
    37. ye = temp[3].toInt(&ok);
    38. //p.drawLine( xs, ys, xe, ye );
    39. // start of labeling.
    40. if(temp[4] == "true")
    41. {
    42. p.setClipRect(windowRect);
    43. xc = (xs + xe) / 2;
    44. yc = (ys + ye) / 2;
    45. if( xs == xe ) angle = pi/2;
    46. else if( ys == ye) angle = 0;
    47. else angle = atan((double)(ye-ys)/(xe-xs));
    48. angle = (angle * 180)/pi;
    49. p.save();
    50. p.translate( xc, yc );
    51. p.rotate( angle );
    52. p.scale(1, -1);
    53. k = "S" + h.setNum(n + 1);
    54. //p.drawText(0, 0, k);
    55. p.restore();
    56. }
    57. }
    58. }
    To copy to clipboard, switch view to plain text mode 

    I have varified that the data is correct.
    I am at a loss and really need some help.
    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: painter problem in new Qt-4.2.3 installation

    How large is the paintSupportLines list?

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: painter problem in new Qt-4.2.3 installation

    Quote Originally Posted by marcel View Post
    How large is the paintSupportLines list?
    anywhere from 1 to maybe a hundredw

    I just changed the "drawLine" to "drawRect" and it worked I got a whole lot of boxes instead of lines. Strange What?
    Last edited by impeteperry; 2nd May 2007 at 07:25.

Similar Threads

  1. How to manage QPainter?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 14:20
  2. Replies: 16
    Last Post: 7th March 2006, 16:57

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.