LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 765|回复: 2

请大牛们帮我看看。。。Qt

[复制链接]
发表于 2009-9-22 16:09:37 | 显示全部楼层 |阅读模式
请大牛们帮我看看。。。
刚开始学习Qt, 模仿着编写了一个程序,但是出现了错误,希望好心人帮我看看,指点指点,呵呵。。。
程序代码为:
先定义了一个头文件:Layout.h
#include <qmainwindow.h>
#include <qstring.h>


class Layout : public QMainWindow
{
    Q_OBJECT
   
public:
    Layout(QWidget *parent = 0, const char *name = 0);
   
private slots:
    void Clicked();
   
};

Layout类的实现如下:Layout.cpp
#include "Layout.h"
#include <qpushbutton.h>
#include <qapplication.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <iostream.h>


Layout:ayout(QWIdget *parent, const char *name) : QMainWindow(parent, name)
{
    QWidget *widget = new QWidget(this);
    setCentralWidget(widget);
   
    QVBoxLayout *buttonBox = new QVBoxLayout(widget, 1, 6, "bottonBox");
    QPushButton *button = new QPushButton("Cancel", this);
    buttonBox->addWidget(new QPushButton("OK", this));
    buttonBox->addWidget(button);
    buttonBox->addStretch(1);
    buttonBox->addWidget(new QPushButton("Help", this));
   
     connect(button, SIGNAL(clicked()), this, SLOT(Clicked()));
   
    QListBox *countryList = new QListBox(this);
    countryList->insertItem("Canada");
    countryList->insertItem("China");
    countryList->insertItem("USA");
   
   
    QHBoxLayout *middleBox = new QHBoxLayout(11);
    middleBox ->addWidget(countryList);
    middleBox ->addLayout(buttonbox);
   
    QVBoxLayout *topLevelBox = new QVBoxLayout(this, 6, 11);
    topLevelBox -> addWidget(new QLabel("select a country", this))
    topLevelBox->addLayout(middleBox);

}


void Layout::Clicked(void)
{
    std::cout<<"you want to cancel"<<endl;

}


主函数:main.cpp
#include <qpushbutton.h>
#include <qapplication.h>
#include <qlistbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <iostream.h>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    Layout *layout = new Layout();
    app.setMainWidget(layout);
    layout->show();
    return app.exec();

}


我make之后出现的错误为:
g++  -o Layout     -L/usr/lib/qt-3.3/lib -lqt-mt -lXext -lX11 -lm
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: ld 返回 1
make: *** [Layout] 错误 1

这应该是基本错误吧,希望大家能帮我解决下,再次谢过。。。
发表于 2009-9-27 11:17:18 | 显示全部楼层
undefined reference to `main'
找不到main函数
回复 支持 反对

使用道具 举报

发表于 2009-9-28 13:13:00 | 显示全部楼层
你make之前有
qmake -project
qmake projectname.pro
吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表