Results 1 to 2 of 2

Thread: why cant i call setGeometry

  1. #1
    Join Date
    Jun 2006
    Posts
    11
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question why cant i call setGeometry

    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)

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: why cant i call setGeometry

    did you add

    QT += qt3support

    in you .pro file ?

Similar Threads

  1. qmake: how to call gsoap
    By niko in forum Newbie
    Replies: 4
    Last Post: 26th April 2008, 11:03
  2. Problem with make (can't call moc.exe)
    By johnny_sparx in forum Installation and Deployment
    Replies: 4
    Last Post: 14th September 2007, 13:02
  3. Replies: 1
    Last Post: 6th April 2006, 12:24
  4. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26
  5. ambiguous call to overloaded function
    By :db:sStrong in forum Qt Programming
    Replies: 18
    Last Post: 10th February 2006, 09:36

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.