I never have had as much trouble with anything I can remember.
As you suggested I setup a new class "MyDrawingFrame" and implemented it as best as I could. It compiles without any warnings
Qt Code:
  1. #ifndef MYDRAWINGFRAME_H
  2. #define MYDRAWINGFRAME_H
  3.  
  4. #include "baseform.h"
  5. #include <qframe.h>
  6. #include <qpainter.h>
  7.  
  8. class MyDrawingFrame : public QFrame
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13.  
  14. public slots:
  15.  
  16. protected:
  17. void paintEvent(QPaintEvent * event);
  18.  
  19. protected slots:
  20.  
  21. private:
  22. QStringList tempList;
  23. QStringList paintSupportLines;
  24. QStringList paintColumns;
  25. QString clearWindow;
  26.  
  27. QRect viewportRect;
  28. QRect windowRect;
  29. QRect clippingRect;
  30. double pi;
  31. int activeLevel;
  32. int functionNumber;
  33. int dwgScaleFactor;
  34. int count;
  35. int num;
  36. int n;
  37. int o1;
  38.  
  39. bool ok;
  40.  
  41. private slots:
  42.  
  43. signals:
  44.  
  45. };
  46.  
  47. void MyDrawingFrame::paintEvent(QPaintEvent * event)
  48. {
  49. QString k, h;
  50. double angle;
  51. int n, xs, xe, ys, ye, xc, yc;
  52. bool ok;
  53.  
  54. QPainter p(this);
  55. QPen pen;
  56. QFont f;
  57.  
  58. if ( paintSupportLines.count () > 0 )
  59. {
  60. f.setFamily ( "Courier" );
  61. f.setPointSize ( dwgScaleFactor );
  62. p.setFont ( f );
  63. pen.setBrush ( Qt::blue );
  64. p.setPen ( pen );
  65. p.setViewport ( viewportRect );
  66. p.setWindow ( windowRect );
  67.  
  68. if ( clearWindow == "erase" ) { p.eraseRect ( windowRect ); clearWindow = "cancel erase"; }
  69. else
  70. {
  71. for ( n = 0; n < paintSupportLines.count(); ++n )
  72. {
  73. //teErrorMessages->setText("F5 key clicked");
  74. p.setClipRect ( clippingRect );
  75. k = paintSupportLines[n];
  76. tempList = k.split ( "," );
  77. xs = tempList[0].toInt ( &ok );
  78. ys = tempList[1].toInt ( &ok );
  79. xe = tempList[2].toInt ( &ok );
  80. ye = tempList[3].toInt ( &ok );
  81. p.drawLine ( 10, 10 * n, 200, 200 );
  82. p.drawLine ( xs, ys, xe, ye );
  83. /// start of labeling.
  84. if ( tempList[4] == "true" )
  85. {
  86. p.setClipRect ( windowRect );
  87. xc = ( xs + xe ) / 2;
  88. yc = ( ys + ye ) / 2;
  89. if ( xs == xe ) angle = pi/2.0;
  90. else if ( ys == ye ) angle = 0.0;
  91. else
  92. {
  93. // angle = atan((double)(ye-ys)/(xe-xs)); /// Why did Qt 4 drop trig functions????
  94. angle = ( double ) ( ye-ys ) / ( xe-xs ); /// hope this works!!!
  95. angle /= 2.0 * pi ;
  96. }
  97. angle = ( angle * 180.0 ) / pi;
  98. p.save();
  99. p.translate ( xc, yc );
  100. p.rotate ( angle ); //teErrorMessages->setText("F5 key clicked");
  101. p.scale ( 1, -1 );
  102. k = "S" + h.setNum ( n + 1 );
  103. p.drawText ( 0, 0, k );
  104. p.restore();
  105. }
  106. }
  107. }
  108. if ( paintColumns.count() > 0 )
  109. {
  110. p.setViewport ( viewportRect );
  111. p.setWindow ( windowRect );
  112. p.setClipRect ( windowRect );
  113. for ( n = 0; n < paintColumns.count(); ++n )
  114. {
  115. k = paintColumns[n];
  116. tempList = k.split ( "," );
  117. xs = tempList[0].toInt ( &ok );
  118. ys = tempList[1].toInt ( &ok );
  119. xe = tempList[2].toInt ( &ok );
  120. ye = tempList[3].toInt ( &ok );
  121. angle = tempList[4].toInt ( &ok );
  122. p.save();
  123. p.translate ( xs, ys );
  124. p.rotate ( angle );
  125. p.fillRect ( -xe/2, -ye/2, xe, ye, Qt::black );
  126. if ( tempList[5] == "true" )
  127. {
  128. f.setFamily ( "Courier" );
  129. f.setPointSize ( ( int ) ( .8 * dwgScaleFactor ) );
  130. p.setFont ( f );
  131. pen.setBrush ( Qt::black );
  132. p.setPen ( pen );
  133. p.rotate ( -angle + 25 );
  134. p.scale ( 1, -1 );
  135. k = "---C" + h.setNum ( n + 1 );
  136. p.drawText ( 0, 0, k );
  137. }
  138. p.restore();
  139. }
  140. }
  141. }
  142. }
  143. #endif // MYDRAWINGFRAME_H
To copy to clipboard, switch view to plain text mode 
Great, but how do I access it to set the values of the variables and activate the paint event itself??. If I "#include "mydrawingframe.h" in my "baseframe.cpp" or anyplace else for that matter I get an
/home/pete/Desktop/pm-straight-C/pm/mydrawingframe.h:65: multiple definition of `MyDrawingFrame:aintEvent(QPaintEvent*)'
baseform.o:/home/pete/Desktop/pm-straight-C/pm/mydrawingframe.h:65: first defined here
collect2: ld returned 1 exit status
make: *** [pm] Error 1
I have also tried setting up a "mydrawingframe.cpp" but I could not get a "MyDrawingFrame::MydrawingFrame( Q??? *parent ) : Q???
t(parent) that did not give an error when compiling.
Sorry to be so long winded, but I am desperate. What in H--- am I missing??? All I want to do is draw some lines of a QFrame widget!!!!!