When I compile my program, I get ld returned 1 exit status error. Here is the code (main.cpp):
#include <QtGui/QApplication>
#include <QPushButton>
#include <QHBoxLayout>
#include <QLineEdit>
#include "widget.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton *okayButtom = new QPushButton("Okay");
QMainWin *mainWin = new QMainWin("Say Pig!");
QHBoxLayout *Hbox = new QHBoxLayout;
QLineEdit *inputBox = new QLineEdit;
mainWin->setWindowTitle("Hello, Pig!");
Hbox->addWidget(inputBox);
Hbox->addWidget(okayButtom);
mainWin->setLayout(Hbox);
mainWin->show();
return app.exec();
}
and this is widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QtGui>
class QMainWin : public QWidget
{
Q_OBJECT
private:
QString WinTitle;
public:
QMainWin(const QString &title, QWidget *parent = 0):WinTitle(title)
{
this->setWindowTitle(WinTitle);
}
~QMainWin();
};
#endif // WIDGET_H
I didn’t use UI file, I only use cpp source file.
QWidget(parent)to the initializing list at theconstructor.
read this http://doc.trolltech.com/4.3/tutorial-t4.html