• 5630阅读
  • 2回复

[建议]:-1: error: collect2: ld returned 1 exit status [复制链接]

上一主题 下一主题
离线xxl104
 
只看楼主 倒序阅读 楼主  发表于: 2011-08-30
关键词: 错误
:-1: error: collect2: ld returned 1 exit status
这种错误除了一般的程序后台运行外,还有可能是定义的slot函数缺少函数体
离线jdwx

只看该作者 1楼 发表于: 2011-08-30
mingw编译器,不管三七二十一,就是这个错误!
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
离线xxl104
只看该作者 2楼 发表于: 2011-08-30
还有可能缺少某些头文件
#include<qwidget.h>
#include<qapplication.h>

#include<QGridLayout>
#include<QTextEdit>
#include<QLineEdit>
#include<QLabel>
#include<QMap>
#include<QPushButton>
#include<QVBoxLayout>
#include<QMessageBox>
#include<QString>




class AddressBook : public QWidget
{
  //  Q_OBJECT
public:
            AddressBook();
private:
    QLineEdit *nameline;
    QTextEdit *addresstext;
    QPushButton *addButton;
        QPushButton *submitButton;
        QPushButton *cancelButton;



};

AddressBook::AddressBook()
{
    QLabel *namelabel = new QLabel("name");
    QLabel *addresslabel = new QLabel("address");
    nameline = new QLineEdit;
    addresstext = new QTextEdit;
    nameline->setReadOnly(true);
    addresstext->setReadOnly(true);
    addButton= new QPushButton("&Add");
    addButton->show();
    submitButton=new QPushButton("&Submit");
        submitButton->hide();
        cancelButton = new QPushButton("&Cancel");
        cancelButton->hide();
        QVBoxLayout *buttonLayout = new QVBoxLayout;
            buttonLayout->addWidget(addButton);
            buttonLayout->addWidget(submitButton);
            buttonLayout->addWidget(cancelButton);
            buttonLayout->addStretch();
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(namelabel,0,0);
    layout->addWidget(nameline,0,1);
    layout->addWidget(addresslabel,1,0,Qt::AlignTop);
    layout->addWidget(addresstext,1,1);
    layout->addLayout(buttonLayout,1,2);
    setLayout(layout);
   //  QObject::connect(addButton,SIGNAL(clicked()),this,SLOT(addContact()));
      // QObject::connect(submitButton,SIGNAL(clicked()),this, SLOT(submitContact()));

      //  QObject::connect(cancelButton,SIGNAL(clicked()),this, SLOT(cancel()));
}


int main(int argc,char **argv)
{
    QApplication app(argc,argv);
   AddressBook *add =new AddressBook;
   add->show();
   return app.exec();
}
还有qobject
快速回复
限100 字节
 
上一个 下一个