PDA

View Full Version : why cant i call setGeometry



freegnu
14th June 2006, 04:00
#include <qapplication.h>
#include <q3scrollview.h>
#include <q3multilineedit.h>
#include <qpushbutton.h>
#include <qfont.h>

class MyMainWindow : public Q3ScrollView
{
public:
MyMainWindow();
private:
QWidget *main;
QPushButton *b1;
QPushButton *b2;
QPushButton *b3;
QPushButton *b4;
QPushButton *b5;
Q3MultiLineEdit *edit;
};

MyMainWindow::MyMainWindow()
{
setGeometry(100, 100, 470, 410);

main = new QWidget(this);
main->resize(400, 400);

b1 = new QPushButton("new", main);
b1->setGeometry(10, 10, 80, 30);
b1->setFont(QFont("Times", 18, QFont::Bold));

b2 = new QPushButton("open", main);
b2->setGeometry(100, 10, 80, 30);
b2->setFont(QFont("Times", 18, QFont::Bold));

b3 = new QPushButton("print", main);
b3->setGeometry(190, 10, 80, 30);
b3->setFont(QFont("Times", 18, QFont::Bold));

b4 = new QPushButton("save", main);
b4->setGeometry(280, 10, 80, 30);
b4->setFont(QFont("Times", 18, QFont::Bold));

b5 = new QPushButton("close", main);
b5->setGeometry(370, 10, 80, 30);
b5->setFont(QFont("Times", 18, QFont::Bold));

edit = new Q3MultiLineEdit(main);
edit->setGeometry(0, 50, 440, 340);
edit->setText("Text edit");

addChild(main);

}

int main(int argc, char **argv)
{
QApplication a(argc, argv);
MyMainWindow w;
a.setMainWidget(&w);
w.show();
return a.exec();
}




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


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)

munna
14th June 2006, 05:59
did you add

QT += qt3support

in you .pro file ?