PDA

View Full Version : Trouble implementing a linked list.



Bonafide
21st February 2010, 04:54
Hey guys,

I'm trying to implement a link list that I made outside of Qt, and implement it within my code. However, when I try to build my project, I get the following errors:

"K:/ProjectManagement/PMGUI/taskLinkList.cpp:9: error: redefinition of 'class taskLinkList' - Line 10"
K:/ProjectManagement/PMGUI/taskLinkList.cpp:10: error: previous definition of 'class taskLinkList' - Line 9"

I get a ton of errors along the lines of "redefined... previously defined here." The link list code works perfectly in VS2008, but not so in Qt 4.6, for whatever reason.

Here's an example of what I'm trying to do:



#include "taskLinkList.cpp"

PMGUI::PMGUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::PMGUI)
{
....

taskLinkList tLink;

....

}

void PMGUI::addTask()
{

QString name = ui->nameLine->text();
QString start = ui->startEdit->text();
QString finish = ui->finishEdit->text();
QString task = ui->taskLine->text();
QString note = ui->noteEdit->toPlainText();
QString completion = ui->completionBox->text();

if (name == "" || task == "")
{
QMessageBox::information(this, tr("Empty Field(s)"), tr("Please enter a name and a task."));
return;
} else {
QMessageBox::information(this, tr("Success!"), tr("\"%1\" has been added to the list of tasks.").arg(name));
}

tLink.add(name, start, finish, task, note, completion);

clear();
}


Here's the declaration of the taskLinkList class:


class taskLinkList
{
private:

struct node
{
QString name;
QString start;
QString finish;
QString task;
QString note;
QString completion;

node *link;
}*p;

public:

taskLinkList();
void add(QString n, QString s, QString f, QString t, QString nt, QString c);
void addFirst(QString n, QString s, QString f, QString t, QString nt, QString c);
void addAfter(int target, QString n, QString s , QString f, QString t, QString nt, QString c);
void del(QString target);
void display();
int count();
~taskLinkList();
};


Thanks for the help,
Bonafide

Lykurg
21st February 2010, 09:58
Show us line 9 and 10 of your taskLinkedList.cpp and shouldn't
#include "taskLinkList.cpp" be
#include "taskLinkList.h"?

Bonafide
21st February 2010, 16:52
I found the problem. I accidentally included the file twice in a .h and .cpp file. That, along with I declared an instance of taskLinkList in the wrong location.

But I have another problem. I've included images for my buttons to have, but when I run my project, these images do not show up. Why's that?

Thanks,
Bonafide

Lykurg
21st February 2010, 21:13
but when I run my project, these images do not show up. Why's that?
Is your path correct/do you use the resource system? On Windows make sure you deliver the needed image plugins with your application.