http://doc.trolltech.com/4.0/porting4.html#qcanvas
according the reference
"The canvas module classes have been renamed and moved to the Qt3Support library"
canvas module classes is also support by qt4, but when i build the code , the error says
it cant find Q3Canvas ...
Qt Code:
  1. #include <qapplication.h>
  2. #include <q3canvas.h>
  3.  
  4. int main(int argc, char **argv)
  5. {
  6. QApplication a( argc, argv );
  7.  
  8. Q3Canvas canvas( 800, 600 );
  9. canvas.setAdvancePeriod(30);
  10.  
  11. Q3CavasView m;
  12. m.setCanvas(&canvas);
  13. a.setMainWidget(&m);
  14.  
  15. Q3CanvasLine* i = new QCanvasLine(&canvas);
  16. i->setPoints( rand()%canvas.width(), rand()%canvas.height(),
  17. rand()%canvas.width(), rand()%canvas.height() );
  18. i->setPen( QPen(QColor(rand()%32*8, rand()%32*8, rand()%32*8), 6) );
  19. i->setZ(rand()%256);
  20. i->show();
  21.  
  22. m.show();
  23.  
  24. return a.exec();
  25. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. main.cpp:2:22: q3canvas.h: No such file or directory
  2. main.cpp: In function `int qMain(int, char**)':
  3. main.cpp:8: error: `Q3Canvas' undeclared (first use this function)
  4. main.cpp:8: error: (Each undeclared identifier is reported only once for each function it appears in.)
  5. main.cpp:8: error: expected `;' before "canvas"
  6. main.cpp:9: error: `canvas' undeclared (first use this function)
  7. main.cpp:11: error: `Q3CavasView' undeclared (first use this function)
  8. main.cpp:11: error: expected `;' before "m"
  9. main.cpp:12: error: `m' undeclared (first use this function)
  10. main.cpp:13: error: 'class QApplication' has no member named 'setMainWidget'
  11. main.cpp:15: error: `Q3CanvasLine' undeclared (first use this function)
  12. main.cpp:15: error: `i' undeclared (first use this function)
  13. main.cpp:15: error: `QCanvasLine' has not been declared
  14. main.cpp:18: error: invalid use of undefined type `struct QColor'
  15. C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwindowdefs.h:37: error: forward declaration of `struct QColor'
  16. main.cpp:18: error: invalid use of undefined type `struct QPen'
  17. C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwindowdefs.h:52: error: forward declaration of `struct QPen'
  18. main.cpp:25:2: warning: no newline at end of file
  19. mingw32-make[1]: *** [tmp\obj\debug_shared\main.o] Error 1
  20. mingw32-make[1]: Leaving directory `C:/Qt/4.1.2/test/test'
  21. mingw32-make: *** [debug-all] Error 2
To copy to clipboard, switch view to plain text mode