Results 1 to 5 of 5

Thread: collect2: ld returned 1 exit status -- working with toolbars

  1. #1
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

    Qt Code:
    1. #ifndef JAUS_H
    2. #define JAUS_H
    3.  
    4. #include <QMainWindow>
    5. #include <QVBoxLayout>
    6.  
    7. namespace Ui {
    8. class jaus;
    9. }
    10.  
    11. class jaus : public QMainWindow {
    12. Q_OBJECT
    13. public:
    14. jaus();
    15. ~jaus();
    16.  
    17. protected:
    18. void changeEvent(QEvent *e);
    19. void contextMenuEvent(QContextMenuEvent *event);
    20.  
    21. private:
    22. Ui::jaus *ui;
    23.  
    24. void createActions();
    25. void createMenus();
    26.  
    27. QMenu *fileMenu;
    28. QMenu *dataMenu;
    29. QMenu *helpMenu;
    30. QAction *exitAct;
    31. QAction *startLogAct;
    32. QAction *stopLogAct;
    33. QAction *debugAct;
    34. QAction *aboutAct;
    35.  
    36. private slots:
    37. void exit();
    38. void startLog();
    39. void stopLog();
    40. void debug();
    41. void about();
    42.  
    43. };
    44.  
    45. #endif // JAUS_H
    46.  
    47.  
    48.  
    49. #include "jaus.h"
    50. #include "ui_jaus.h"
    51.  
    52. jaus::jaus()
    53. {
    54. QWidget *widget = new QWidget;
    55. setCentralWidget(widget);
    56.  
    57. QWidget *topFiller = new QWidget;
    58. topFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    59.  
    60. QWidget *bottomFiller = new QWidget;
    61. bottomFiller->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    62.  
    63. QVBoxLayout *layout = new QVBoxLayout;
    64. layout->setMargin(5);
    65. layout->addWidget(topFiller);
    66. layout->addWidget(bottomFiller);
    67. widget->setLayout(layout);
    68.  
    69. createActions();
    70. createMenus();
    71.  
    72. QString message = tr("JAUS Communicator - Version 0.1");
    73. statusBar()->showMessage(message);
    74. }
    75.  
    76.  
    77. jaus::~jaus()
    78. {
    79. delete ui;
    80. }
    81.  
    82. void jaus::changeEvent(QEvent *e)
    83. {
    84. QMainWindow::changeEvent(e);
    85. switch (e->type()) {
    86. case QEvent::LanguageChange:
    87. ui->retranslateUi(this);
    88. break;
    89. default:
    90. break;
    91. }
    92. }
    93.  
    94. void jaus::createActions()
    95. {
    96. exitAct = new QAction(tr("&Exit"), this);
    97. exitAct->setStatusTip(tr("Exit the application"));
    98. connect(exitAct, SIGNAL(triggered()), this, SLOT(exit()));
    99.  
    100. startLogAct = new QAction(tr("&Logging"), this);
    101. startLogAct->setStatusTip(tr("Enables Logging"));
    102. connect(startLogAct, SIGNAL(triggered()), this, SLOT(startLog()));
    103.  
    104. debugAct = new QAction(tr("&Debug"), this);
    105. debugAct->setStatusTip(tr("Turns Debugging On"));
    106. connect(debugAct, SIGNAL(triggered()), this, SLOT(debug()));
    107.  
    108. aboutAct = new QAction(tr("&About"), this);;
    109. connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    110. }
    111.  
    112. void jaus::createMenus()
    113. {
    114. fileMenu = menuBar()->addMenu(tr("&File"));
    115. fileMenu->addAction(exitAct);
    116. fileMenu->addSeparator();
    117.  
    118. dataMenu = menuBar()->addMenu(tr("&Data"));
    119. dataMenu->addAction(startLogAct);
    120. dataMenu->addAction(debugAct);
    121. dataMenu->addSeparator();
    122.  
    123. helpMenu = menuBar()->addMenu(tr("&Help"));
    124. helpMenu->addAction(aboutAct);
    125. }
    126.  
    127. void jaus::about()
    128. {
    129.  
    130. }
    131.  
    132. void jaus::exit()
    133. {
    134.  
    135. }
    136.  
    137. void jaus::debug()
    138. {
    139.  
    140. }
    141.  
    142.  
    143. void jaus::startLog()
    144. {
    145.  
    146. }
    147.  
    148. void jaus::stopLog()
    149. {
    150.  
    151. }
    152.  
    153.  
    154.  
    155. #include <QtGui/QApplication>
    156. #include "jaus.h"
    157.  
    158. int main(int argc, char *argv[])
    159. {
    160. QApplication a(argc, argv);
    161. jaus w;
    162. w.show();
    163. return a.exec();
    164. }
    To copy to clipboard, switch view to plain text mode 

    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!!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: collect2: ld returned 1 exit status -- working with toolbars

    You can create your menu in designer.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  4. #4
    Join Date
    Jan 2010
    Posts
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  5. #5
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: collect2: ld returned 1 exit status -- working with toolbars


Similar Threads

  1. collect2: ld returned 1 exit status
    By qtnewbie123 in forum Installation and Deployment
    Replies: 9
    Last Post: 12th July 2011, 19:51
  2. Collect2:Id Returned 1 exit status
    By c_srikanth1984 in forum Qt Programming
    Replies: 9
    Last Post: 14th February 2010, 05:58
  3. error: collect2: ld returned 1 exit status
    By nataly in forum Qt Programming
    Replies: 4
    Last Post: 13th October 2009, 14:39
  4. collect2: ld returned 1 exit status error
    By gmsk19 in forum Qt Tools
    Replies: 11
    Last Post: 25th July 2009, 03:05
  5. collect2: ld returned 1 exit status
    By assismvla in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 02:51

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.