collect2: ld returned 1 exit status -- working with toolbars
so i'm trying to implement some menus into my programs -- i have to be doing it the hard way. Here's my code in its entirety ... please, someone tell me there's an easier way!
Code:
#ifndef JAUS_H
#define JAUS_H
#include <QMainWindow>
#include <QVBoxLayout>
namespace Ui {
class jaus;
}
Q_OBJECT
public:
jaus();
~jaus();
protected:
private:
Ui::jaus *ui;
void createActions();
void createMenus();
private slots:
void exit();
void startLog();
void stopLog();
void debug();
void about();
};
#endif // JAUS_H
#include "jaus.h"
#include "ui_jaus.h"
jaus::jaus()
{
setCentralWidget(widget);
layout->setMargin(5);
layout->addWidget(topFiller);
layout->addWidget(bottomFiller);
widget->setLayout(layout);
createActions();
createMenus();
QString message
= tr
("JAUS Communicator - Version 0.1");
statusBar()->showMessage(message);
}
jaus::~jaus()
{
delete ui;
}
void jaus
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
void jaus::createActions()
{
exitAct
= new QAction(tr
("&Exit"),
this);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(exit()));
startLogAct
= new QAction(tr
("&Logging"),
this);
startLogAct->setStatusTip(tr("Enables Logging"));
connect(startLogAct, SIGNAL(triggered()), this, SLOT(startLog()));
debugAct
= new QAction(tr
("&Debug"),
this);
debugAct->setStatusTip(tr("Turns Debugging On"));
connect(debugAct, SIGNAL(triggered()), this, SLOT(debug()));
aboutAct
= new QAction(tr
("&About"),
this);;
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}
void jaus::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(exitAct);
fileMenu->addSeparator();
dataMenu = menuBar()->addMenu(tr("&Data"));
dataMenu->addAction(startLogAct);
dataMenu->addAction(debugAct);
dataMenu->addSeparator();
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(aboutAct);
}
void jaus::about()
{
}
void jaus::exit()
{
}
void jaus::debug()
{
}
void jaus::startLog()
{
}
void jaus::stopLog()
{
}
#include <QtGui/QApplication>
#include "jaus.h"
int main(int argc, char *argv[])
{
jaus w;
w.show();
return a.exec();
}
When I compile this code I get the collect2: ld returned 1 exit status error message. I have no clue what this means, but hopefully I can find an easier way (maybe a drag/drop option??) to add menus to my programs. Thanks for any help!!
Re: collect2: ld returned 1 exit status -- working with toolbars
I don't see where you allocates memory for ui, but you are trying to call some ui methods in jaus::changeEvent. it must lead to crash.
Re: collect2: ld returned 1 exit status -- working with toolbars
You can create your menu in designer.
Re: collect2: ld returned 1 exit status -- working with toolbars
That would be great - can you tell me how? I couldn't find it anywhere
Re: collect2: ld returned 1 exit status -- working with toolbars