Re: This makes no sense...
Isn't it quite obvious, that you have something wrong in included file?
Code:
#include "mainlogin.h"
Look for missing ";" or "}"
Re: This makes no sense...
Quote:
Originally Posted by
Rachol
Look for missing ";" or "}"
probably a missing ";" at the end of the class definition.
Re: This makes no sense...
Checked the header... Do you guys see anything off?
Code:
#ifndef MAINLOGIN_H
#define MAINLOGIN_H
#include <QWidget>
#include <QDialog>
#include "mainwin.h"
namespace Ui {
class mainlogin;
{
Q_OBJECT
public:
explicit mainlogin
(QWidget *parent
= 0);
~mainlogin();
{
if (mainlogin->objectName().isEmpty())
mainlogin
->setObjectName
(QString::fromUtf8("mainlogin"));
mainlogin->resize(237, 117);
horizontalLayout_4
->setObjectName
(QString::fromUtf8("horizontalLayout_4"));
horizontalLayout_4->addItem(horizontalSpacer_3);
verticalLayout_3
->setObjectName
(QString::fromUtf8("verticalLayout_3"));
verticalLayout_3->addItem(verticalSpacer);
verticalLayout_2
->setObjectName
(QString::fromUtf8("verticalLayout_2"));
verticalLayout
->setObjectName
(QString::fromUtf8("verticalLayout"));
horizontalLayout
->setObjectName
(QString::fromUtf8("horizontalLayout"));
label
= new QLabel(mainlogin
);
label
->setObjectName
(QString::fromUtf8("label"));
horizontalLayout->addWidget(label);
leUsername
->setObjectName
(QString::fromUtf8("leUsername"));
horizontalLayout->addWidget(leUsername);
verticalLayout->addLayout(horizontalLayout);
horizontalLayout_2
->setObjectName
(QString::fromUtf8("horizontalLayout_2"));
label_2
= new QLabel(mainlogin
);
label_2
->setObjectName
(QString::fromUtf8("label_2"));
horizontalLayout_2->addWidget(label_2);
lePassword
->setObjectName
(QString::fromUtf8("lePassword"));
horizontalLayout_2->addWidget(lePassword);
verticalLayout->addLayout(horizontalLayout_2);
verticalLayout_2->addLayout(verticalLayout);
horizontalLayout_3
->setObjectName
(QString::fromUtf8("horizontalLayout_3"));
horizontalLayout_3->addItem(horizontalSpacer_2);
bLogin
->setObjectName
(QString::fromUtf8("bLogin"));
horizontalLayout_3->addWidget(bLogin);
horizontalLayout_3->addItem(horizontalSpacer);
verticalLayout_2->addLayout(horizontalLayout_3);
verticalLayout_3->addLayout(verticalLayout_2);
verticalLayout_3->addItem(verticalSpacer_2);
horizontalLayout_4->addLayout(verticalLayout_3);
horizontalLayout_4->addItem(horizontalSpacer_4);
retranslateUi(mainlogin);
} // setupUi
void retranslateUi
(QDialog *mainlogin
) {
} // retranslateUi
void login()
{
QFile loginsFile
("/logins.txt");
if(loginsFile.size() == 0 || loginsFile.exists() == false)
{
error.setText("There are no logins stored. Please reinstall the program.");
error.exec();
return;
}
QString enteredUsername
= ui
->leUsername
->text
();
QString enteredPassword
= ui
->lePassword
->text
();
QString loadedLogins
= loginsStream.
readAll();
int usernameCorrect = 0;
QString filedUsername
= loadedLogins.
section("|",
1,
1);
QString filedPassword
= loadedLogins.
section("|",
2,
2);
debug.setText(enteredUsername);
debug.exec();
debug.setText(enteredPassword);
debug.exec();
debug.setText(loadedLogins);
debug.exec();
debug.setText(filedUsername);
debug.exec();
debug.setText(filedPassword);
debug.exec();
if(enteredUsername != filedUsername)
{
error.setText("Username not found!");
error.exec();
usernameCorrect = 0;
}
else
{
if(enteredPassword == filedPassword)
{
mainwin *a = new mainwin;
a->show();
}
}
} // login()
private:
Ui::mainlogin *ui;
}; // Class mainlogin
QT_END_NAMESPACE
#endif // MAINLOGIN_H
EDIT: Here is the other header:
Code:
#ifndef MAINWIN_H
#define MAINWIN_H
#include <QWidget>
#include <QtGui>
{
Q_OBJECT
public:
{
setAttribute(Qt::WA_DeleteOnClose); // make sure memory is cleaned up
// Temporary
layout
->addWidget
( new QLabel("Label 1",
this) );
layout
->addWidget
( new QLabel("Label 2",
this) );
setLayout(layout);
}
};
#endif // MAINWIN_H
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.
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..
Quote:
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.
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.
Re: This makes no sense...
Quote:
Originally Posted by
Lykurg
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...
Quote:
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
Code:
#include <QApplication>
#include "mainwin.h"
int main(int argc, char **argv)
{
mainwin w;
w.show();
return app.exec();
}
What do you guys think? Fail on my part or fail on the compilers fault?
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.
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.
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.
Re: This makes no sense...
Quote:
Originally Posted by
sapslaj
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.
Re: This makes no sense...
Nevermind... Just wondering about my debugging problem. I never hit this problem before.