Results 1 to 4 of 4

Thread: Trouble implementing a linked list.

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

    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 06:02.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Trouble implementing a linked list.

    Show us line 9 and 10 of your taskLinkedList.cpp and shouldn't
    Qt Code:
    1. #include "taskLinkList.cpp"
    To copy to clipboard, switch view to plain text mode 
    be
    Qt Code:
    1. #include "taskLinkList.h"
    To copy to clipboard, switch view to plain text mode 
    ?

  3. #3
    Join Date
    Feb 2010
    Posts
    22
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trouble implementing a linked list.

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Trouble implementing a linked list.

    Quote Originally Posted by Bonafide View Post
    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.

Similar Threads

  1. implementing 'scrollview'
    By rishiraj in forum Newbie
    Replies: 1
    Last Post: 18th December 2008, 12:23
  2. Implementing threads...
    By Abc in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2008, 08:41
  3. implementing drawForeGround
    By Wirloff in forum Newbie
    Replies: 9
    Last Post: 11th April 2007, 16:03
  4. Implementing paint()
    By Wirloff in forum Qt Programming
    Replies: 3
    Last Post: 10th April 2007, 10:29
  5. Implementing IME using QT
    By pmohod in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2007, 12: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.