Results 1 to 4 of 4

Thread: Trouble implementing a linked list.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2010
    Posts
    22
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Trouble implementing a linked list.

    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:

    Qt Code:
    1. #include "taskLinkList.cpp"
    2.  
    3. PMGUI::PMGUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::PMGUI)
    4. {
    5. ....
    6.  
    7. taskLinkList tLink;
    8.  
    9. ....
    10.  
    11. }
    12.  
    13. void PMGUI::addTask()
    14. {
    15.  
    16. QString name = ui->nameLine->text();
    17. QString start = ui->startEdit->text();
    18. QString finish = ui->finishEdit->text();
    19. QString task = ui->taskLine->text();
    20. QString note = ui->noteEdit->toPlainText();
    21. QString completion = ui->completionBox->text();
    22.  
    23. if (name == "" || task == "")
    24. {
    25. QMessageBox::information(this, tr("Empty Field(s)"), tr("Please enter a name and a task."));
    26. return;
    27. } else {
    28. QMessageBox::information(this, tr("Success!"), tr("\"%1\" has been added to the list of tasks.").arg(name));
    29. }
    30.  
    31. tLink.add(name, start, finish, task, note, completion);
    32.  
    33. clear();
    34. }
    To copy to clipboard, switch view to plain text mode 

    Here's the declaration of the taskLinkList class:
    Qt Code:
    1. class taskLinkList
    2. {
    3. private:
    4.  
    5. struct node
    6. {
    7. QString name;
    8. QString start;
    9. QString finish;
    10. QString task;
    11. QString note;
    12. QString completion;
    13.  
    14. node *link;
    15. }*p;
    16.  
    17. public:
    18.  
    19. taskLinkList();
    20. void add(QString n, QString s, QString f, QString t, QString nt, QString c);
    21. void addFirst(QString n, QString s, QString f, QString t, QString nt, QString c);
    22. void addAfter(int target, QString n, QString s , QString f, QString t, QString nt, QString c);
    23. void del(QString target);
    24. void display();
    25. int count();
    26. ~taskLinkList();
    27. };
    To copy to clipboard, switch view to plain text mode 

    Thanks for the help,
    Bonafide
    Last edited by Bonafide; 21st February 2010 at 07:02.

Similar Threads

  1. implementing 'scrollview'
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 18th December 2008, 13:23
  2. Implementing threads...
    By Abc in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2008, 09:41
  3. implementing drawForeGround
    By Wirloff in forum Newbie
    Replies: 9
    Last Post: 11th April 2007, 17:03
  4. Implementing paint()
    By Wirloff in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2007, 11:29
  5. Implementing IME using QT
    By pmohod in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2007, 13:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.