Hello everyone ,,

first of all I'm using Qt3 , and I work on Debian,,

I try to modify drawlines.cpp code in example package of QT3 because I want my own painter program ,,

what I want in my program is to have a white box and some other buttons ,, but I have a problem in my try , I want the drawn lines just appears in this white box but now the user can draw anywhere in the frame ,, I try to solve this problem by passing the name of the label (the white box) to the constructor of QPainter , But I have something strange mybe it is not strange for advanced programmer ,, the problem was the user could draw correctly but she has to put the mouse not on the white space BUT in a place above it with about 7 cm !
here is the modified code

Qt Code:
  1. #include <qpainter.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. const int MAXPOINTS = 4000; // maximum number of points
  7.  
  8.  
  9. void mousewriting::init()
  10. {
  11.  
  12. count = 0;
  13. down = FALSE;
  14. points = new QPoint[MAXPOINTS];
  15.  
  16. }
  17.  
  18.  
  19. void mousewriting::destroy()
  20. {
  21.  
  22. delete[] points;
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. void mousewriting::mousePressEvent( QMouseEvent * )
  30. {
  31.  
  32. down = TRUE;
  33. count = 0;
  34. }
  35.  
  36.  
  37. void mousewriting::mouseMoveEvent( QMouseEvent *e )
  38. {
  39.  
  40. if ( down && count < MAXPOINTS ) {
  41. QPainter paint(this); \\ I replace this by textLabel1 (the white box)
  42. // paint.setWindow ( 170, 140, 400, 500 );
  43. points[count++] = e->pos(); // add point
  44. paint.drawPoint( e->pos() ); // plot point
  45.  
  46. for ( int i=0; i<count-1; i++ ) {
  47. for ( int j=i+1; j<i+2; j++ ) {
  48.  
  49. paint.setPen( blue);
  50. paint.drawLine( points[i], points[j] ); // draw line
  51. paint.flush() ;
  52. }//end inner for
  53. }//end outer for
  54.  
  55.  
  56. }//end if
  57.  
  58. }//end funcion
  59.  
  60.  
  61. void mousewriting::cleardraw()
  62. {
  63. down= false;
  64. update();
  65. }
To copy to clipboard, switch view to plain text mode 

could anyone help me ,, or give me an idea to have a frame and iside it a white space for drawing in it ??

another question , I try to draw using functions of QPainter class in the load of the program , I put it the code in the init() but it does not draw ,, is there any way to draw shapes using in the load time ?