Qt Code:
  1. #include <qapplication.h>
  2. #include <q3scrollview.h>
  3. #include <q3multilineedit.h>
  4. #include <qpushbutton.h>
  5. #include <qfont.h>
  6.  
  7. class MyMainWindow : public Q3ScrollView
  8. {
  9. public:
  10. MyMainWindow();
  11. private:
  12. QWidget *main;
  13. Q3MultiLineEdit *edit;
  14. };
  15.  
  16. MyMainWindow::MyMainWindow()
  17. {
  18. setGeometry(100, 100, 470, 410);
  19.  
  20. main = new QWidget(this);
  21. main->resize(400, 400);
  22.  
  23. b1 = new QPushButton("new", main);
  24. b1->setGeometry(10, 10, 80, 30);
  25. b1->setFont(QFont("Times", 18, QFont::Bold));
  26.  
  27. b2 = new QPushButton("open", main);
  28. b2->setGeometry(100, 10, 80, 30);
  29. b2->setFont(QFont("Times", 18, QFont::Bold));
  30.  
  31. b3 = new QPushButton("print", main);
  32. b3->setGeometry(190, 10, 80, 30);
  33. b3->setFont(QFont("Times", 18, QFont::Bold));
  34.  
  35. b4 = new QPushButton("save", main);
  36. b4->setGeometry(280, 10, 80, 30);
  37. b4->setFont(QFont("Times", 18, QFont::Bold));
  38.  
  39. b5 = new QPushButton("close", main);
  40. b5->setGeometry(370, 10, 80, 30);
  41. b5->setFont(QFont("Times", 18, QFont::Bold));
  42.  
  43. edit = new Q3MultiLineEdit(main);
  44. edit->setGeometry(0, 50, 440, 340);
  45. edit->setText("Text edit");
  46.  
  47. addChild(main);
  48.  
  49. }
  50.  
  51. int main(int argc, char **argv)
  52. {
  53. QApplication a(argc, argv);
  54. MyMainWindow w;
  55. a.setMainWidget(&w);
  56. w.show();
  57. return a.exec();
  58. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. main.cpp:2:26: q3scrollview.h: No such file or directory
  2. main.cpp:3:29: q3multilineedit.h: No such file or directory
  3. main.cpp:8: error: expected class-name before '{' token
  4. main.cpp:18: error: ISO C++ forbids declaration of `Q3MultiLineEdit' with no type
  5. main.cpp:18: error: expected `;' before '*' token
  6. main.cpp: In constructor `MyMainWindow::MyMainWindow()':
  7. main.cpp:23: error: `setGeometry' undeclared (first use this function)
  8. main.cpp:23: error: (Each undeclared identifier is reported only once for each function it appears in.)
  9. main.cpp:25: error: no matching function for call to `QWidget::QWidget(MyMainWindow* const)'
  10. C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwidget.h:635: note: candidates are: QWidget::QWidget(const QWidget&)
  11. C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwidget.h:596: note: QWidget::QWidget(QWidgetPrivate&, QWidge
  12. *, Qt::WFlags)
  13. C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwidget.h:183: note: QWidget::QWidget(QWidget*, Qt::WFlags)
  14. main.cpp:48: error: `edit' undeclared (first use this function)
  15. main.cpp:48: error: `Q3MultiLineEdit' has not been declared
  16. main.cpp:52: error: `addChild' undeclared (first use this function)
  17. main.cpp: In function `int qMain(int, char**)':
  18. main.cpp:60: error: 'class QApplication' has no member named 'setMainWidget'
  19. main.cpp:61: error: 'class MyMainWindow' has no member named 'show'
  20. main.cpp:63:2: warning: no newline at end of file
  21. mingw32-make[1]: *** [tmp\obj\debug_shared\main.o] Error 1
  22. mingw32-make[1]: Leaving directory `C:/Qt/4.1.2/test/scroll/scrollview'
  23. mingw32-make: *** [debug-all] Error 2
To copy to clipboard, switch view to plain text mode 

1) why the compile cant find q3scrollview.h and q3multilineedit.h
2) class MyMainWindow : public Q3ScrollView , and Q3ScrollView is inherit QWidget,
why it cant call the funtion setGeometry
3)error: no matching function for call to `QWidget::QWidget(MyMainWindow* const)'
i find the construct is QWidget ( QWidget * parent = 0, Qt::WFlags f = 0 ), but i cant understand it, and why dose it reference
QWidget::QWidget(const QWidget&)
QWidget::QWidget(QWidgetPrivate&, QWidge*, Qt::WFlags)
QWidget::QWidget(QWidget*, Qt::WFlags)