Results 1 to 13 of 13

Thread: This makes no sense...

  1. #1
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default This makes no sense...

    So I have this code...
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainlogin.h"
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7. mainlogin w;
    8. w.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    I get the compiler error:
    Qt Code:
    1. main.cpp:10: error: expected '}' at end of input
    To copy to clipboard, switch view to plain text mode 

    So this code works...
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainlogin.h"
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7. mainlogin w;
    8. w.show();
    9. return app.exec();
    10. }}
    To copy to clipboard, switch view to plain text mode 

    Then I get this error:
    Qt Code:
    1. moc_mainlogin.cpp:68: error: expected '}' at end of input
    To copy to clipboard, switch view to plain text mode 

    After I fix that, I get
    Qt Code:
    1. c:\ndk_buildrepos\qt-desktop\src\winmain\qtmain_win.cpp:131: error: undefined reference to `qMain(int, char**)'
    To copy to clipboard, switch view to plain text mode 

    Is anyone else having this problem?

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: This makes no sense...

    Isn't it quite obvious, that you have something wrong in included file?

    Qt Code:
    1. #include "mainlogin.h"
    To copy to clipboard, switch view to plain text mode 

    Look for missing ";" or "}"
    Don't write a post just to thank someone, use "Thanks" button.

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: This makes no sense...

    Quote Originally Posted by Rachol View Post
    Look for missing ";" or "}"
    probably a missing ";" at the end of the class definition.

  4. #4
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: This makes no sense...

    Checked the header... Do you guys see anything off?

    Qt Code:
    1. #ifndef MAINLOGIN_H
    2. #define MAINLOGIN_H
    3.  
    4. #include <QWidget>
    5. #include <QDialog>
    6. #include "mainwin.h"
    7.  
    8. namespace Ui {
    9. class mainlogin;
    10.  
    11. class mainlogin : public QDialog
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit mainlogin(QWidget *parent = 0);
    17. ~mainlogin();
    18. QHBoxLayout *horizontalLayout_4;
    19. QSpacerItem *horizontalSpacer_3;
    20. QVBoxLayout *verticalLayout_3;
    21. QSpacerItem *verticalSpacer;
    22. QVBoxLayout *verticalLayout_2;
    23. QVBoxLayout *verticalLayout;
    24. QHBoxLayout *horizontalLayout;
    25. QLabel *label;
    26. QLineEdit *leUsername;
    27. QHBoxLayout *horizontalLayout_2;
    28. QLabel *label_2;
    29. QLineEdit *lePassword;
    30. QHBoxLayout *horizontalLayout_3;
    31. QSpacerItem *horizontalSpacer_2;
    32. QPushButton *bLogin;
    33. QSpacerItem *horizontalSpacer;
    34. QSpacerItem *verticalSpacer_2;
    35. QSpacerItem *horizontalSpacer_4;
    36.  
    37. void setupUi(QDialog *mainlogin)
    38. {
    39. if (mainlogin->objectName().isEmpty())
    40. mainlogin->setObjectName(QString::fromUtf8("mainlogin"));
    41. mainlogin->resize(237, 117);
    42. horizontalLayout_4 = new QHBoxLayout(mainlogin);
    43. horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4"));
    44. horizontalSpacer_3 = new QSpacerItem(14, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    45.  
    46. horizontalLayout_4->addItem(horizontalSpacer_3);
    47.  
    48. verticalLayout_3 = new QVBoxLayout();
    49. verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
    50. verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
    51.  
    52. verticalLayout_3->addItem(verticalSpacer);
    53.  
    54. verticalLayout_2 = new QVBoxLayout();
    55. verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
    56. verticalLayout = new QVBoxLayout();
    57. verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    58. horizontalLayout = new QHBoxLayout();
    59. horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
    60. label = new QLabel(mainlogin);
    61. label->setObjectName(QString::fromUtf8("label"));
    62.  
    63. horizontalLayout->addWidget(label);
    64.  
    65. leUsername = new QLineEdit(mainlogin);
    66. leUsername->setObjectName(QString::fromUtf8("leUsername"));
    67.  
    68. horizontalLayout->addWidget(leUsername);
    69.  
    70.  
    71. verticalLayout->addLayout(horizontalLayout);
    72.  
    73. horizontalLayout_2 = new QHBoxLayout();
    74. horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
    75. label_2 = new QLabel(mainlogin);
    76. label_2->setObjectName(QString::fromUtf8("label_2"));
    77.  
    78. horizontalLayout_2->addWidget(label_2);
    79.  
    80. lePassword = new QLineEdit(mainlogin);
    81. lePassword->setObjectName(QString::fromUtf8("lePassword"));
    82.  
    83. horizontalLayout_2->addWidget(lePassword);
    84.  
    85.  
    86. verticalLayout->addLayout(horizontalLayout_2);
    87.  
    88.  
    89. verticalLayout_2->addLayout(verticalLayout);
    90.  
    91. horizontalLayout_3 = new QHBoxLayout();
    92. horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
    93. horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    94.  
    95. horizontalLayout_3->addItem(horizontalSpacer_2);
    96.  
    97. bLogin = new QPushButton(mainlogin);
    98. bLogin->setObjectName(QString::fromUtf8("bLogin"));
    99.  
    100. horizontalLayout_3->addWidget(bLogin);
    101.  
    102. horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    103.  
    104. horizontalLayout_3->addItem(horizontalSpacer);
    105.  
    106.  
    107. verticalLayout_2->addLayout(horizontalLayout_3);
    108.  
    109.  
    110. verticalLayout_3->addLayout(verticalLayout_2);
    111.  
    112. verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
    113.  
    114. verticalLayout_3->addItem(verticalSpacer_2);
    115.  
    116.  
    117. horizontalLayout_4->addLayout(verticalLayout_3);
    118.  
    119. horizontalSpacer_4 = new QSpacerItem(14, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    120.  
    121. horizontalLayout_4->addItem(horizontalSpacer_4);
    122.  
    123.  
    124. retranslateUi(mainlogin);
    125.  
    126. QMetaObject::connectSlotsByName(mainlogin);
    127. } // setupUi
    128.  
    129. void retranslateUi(QDialog *mainlogin)
    130. {
    131. mainlogin->setWindowTitle(QApplication::translate("mainlogin", "Dialog", 0, QApplication::UnicodeUTF8));
    132. label->setText(QApplication::translate("mainlogin", "Username:", 0, QApplication::UnicodeUTF8));
    133. label_2->setText(QApplication::translate("mainlogin", "Password:", 0, QApplication::UnicodeUTF8));
    134. bLogin->setText(QApplication::translate("mainlogin", "Login", 0, QApplication::UnicodeUTF8));
    135. } // retranslateUi
    136.  
    137.  
    138. void login()
    139. {
    140. QFile loginsFile("/logins.txt");
    141.  
    142. if(loginsFile.size() == 0 || loginsFile.exists() == false)
    143. {
    144. QMessageBox error;
    145. error.setText("There are no logins stored. Please reinstall the program.");
    146. error.exec();
    147. return;
    148. }
    149. QTextStream loginsStream(&loginsFile);
    150.  
    151. QString enteredUsername = ui->leUsername->text();
    152. QString enteredPassword = ui->lePassword->text();
    153.  
    154. QString loadedLogins = loginsStream.readAll();
    155.  
    156. int usernameCorrect = 0;
    157.  
    158. QString filedUsername = loadedLogins.section("|", 1, 1);
    159. QString filedPassword = loadedLogins.section("|", 2, 2);
    160.  
    161. QMessageBox debug;
    162. debug.setText(enteredUsername);
    163. debug.exec();
    164. debug.setText(enteredPassword);
    165. debug.exec();
    166. debug.setText(loadedLogins);
    167. debug.exec();
    168. debug.setText(filedUsername);
    169. debug.exec();
    170. debug.setText(filedPassword);
    171. debug.exec();
    172.  
    173.  
    174.  
    175. if(enteredUsername != filedUsername)
    176. {
    177. QMessageBox error;
    178. error.setText("Username not found!");
    179. error.exec();
    180. usernameCorrect = 0;
    181. }
    182.  
    183. else
    184. {
    185. if(enteredPassword == filedPassword)
    186. {
    187. mainwin *a = new mainwin;
    188. a->show();
    189. }
    190. }
    191. } // login()
    192.  
    193.  
    194. private:
    195. Ui::mainlogin *ui;
    196. }; // Class mainlogin
    197.  
    198. QT_END_NAMESPACE
    199.  
    200. #endif // MAINLOGIN_H
    To copy to clipboard, switch view to plain text mode 

    EDIT: Here is the other header:

    Qt Code:
    1. #ifndef MAINWIN_H
    2. #define MAINWIN_H
    3.  
    4. #include <QWidget>
    5. #include <QtGui>
    6.  
    7. class mainwin : public QWidget
    8. {
    9. Q_OBJECT
    10. public:
    11. mainwin(QWidget *p = 0): QWidget(p)
    12. {
    13. setAttribute(Qt::WA_DeleteOnClose); // make sure memory is cleaned up
    14.  
    15. // Temporary
    16. QVBoxLayout *layout = new QVBoxLayout;
    17. layout->addWidget( new QLabel("Label 1", this) );
    18. layout->addWidget( new QLabel("Label 2", this) );
    19. setLayout(layout);
    20. }
    21. };
    22.  
    23. #endif // MAINWIN_H
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: This makes no sense...

    I see your using QT_END_NAMESPACE without a QT_BEGIN_NAMESPACE, so if the former resolves to null, then you'll be missing a '}' in that file.

  6. #6
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: This makes no sense...

    Nevermind. It was just a bug, reinstalled Qt and rewrote most of the code. Everything is working on my side. Now its just all of the 300 errors of the Qt headers. Well, I do one error..
    mainlogin.cpp:3: error: definition of implicitly-declared 'mainlogin::mainlogin(const mainlogin&)'
    But I'm sure I know the fix for that. And I just cleared all of the Qt Errors. Rouge macros was to blame.
    Last edited by sapslaj; 5th September 2011 at 18:15.

  7. #7
    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: This makes no sense...

    Ehm, what bug? The only bugs I can see are in your code... E.g. mainlogin.h line 10 misses a } for closing the namespace.

  8. #8
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: This makes no sense...

    Quote Originally Posted by Lykurg View Post
    Ehm, what bug? The only bugs I can see are in your code... E.g. mainlogin.h line 10 misses a } for closing the namespace.
    I see that now... The odd thing is that Qt Actually generated most of the code... So that's worrying.. Anyways, I fixed it. And now for my debugging problem...
    Debugging starts
    QWidget: Must construct a QApplication before a QPaintDevice
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.
    Debugging has finished
    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "mainwin.h"
    4.  
    5. int main(int argc, char **argv)
    6. {
    7. QApplication app(argc, argv);
    8. mainwin w;
    9. w.show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    What do you guys think? Fail on my part or fail on the compilers fault?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: This makes no sense...

    Qt generates correct code. It's only when you try to "improve" that mistakes start to occur. Especially the code that has this nice warning about not modifying a file because it is autogenerated.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: This makes no sense...

    No really........... I'm not trying to improve that code, I just get Qt to generate some of the code, then I do the rest. I never touch anything else.

  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: This makes no sense...

    You still modified a file which is auto generated and not meant to be modified. I very much doubt UIC would have autogenerated the "login" method. It doesn't even belong in this class.

    So you probably accidentally altered the file in such a way which caused the errors.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: This makes no sense...

    Quote Originally Posted by sapslaj View Post
    No really........... I'm not trying to improve that code, I just get Qt to generate some of the code, then I do the rest. I never touch anything else.
    In C++ you usually "improve" code by subclassing.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Sep 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: This makes no sense...

    Nevermind... Just wondering about my debugging problem. I never hit this problem before.

Similar Threads

  1. what would make more sense?
    By jajdoo in forum Newbie
    Replies: 1
    Last Post: 27th July 2011, 22:54
  2. Replies: 5
    Last Post: 24th May 2011, 11:36
  3. Replies: 7
    Last Post: 13th November 2010, 07:58
  4. designer intelli-sense
    By mhoover in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2010, 13:25
  5. qsqldatabase does not sense db disconnect
    By rburge in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2006, 18:59

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.