Re: Program crashes (SIGSEGV)
I've changed that, but I have changed the QQMsnApplication class (there were errors):
Code:
debugger* QQMsnApplication::debug()
{
return m_debug;
}
cmsn* QQMsnApplication::msn()
{
return m_msn;
}
Window_Login* QQMsnApplication::window_login()
{
return m_window_login;
}
Window_Login_Busy* QQMsnApplication::login_busy()
{
return m_login_busy;
}
But as I said, I still get errors, these are:
Quote:
/home/quinten/QQMsn_test/src/window_login.cpp: In member function ‘void Window_Login::startLogin()’:
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: ‘QQMsnApp’ was not declared in this scope
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected primary-expression before ‘>’ token
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected primary-expression before ‘>’ token
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected primary-expression before ‘>’ token
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected primary-expression before ‘>’ token
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected primary-expression before ‘>’ token
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `)' before ‘;’ token
make[2]: *** [CMakeFiles/QQMsn.dir/src/window_login.o] Fout 1
make[1]: *** [CMakeFiles/QQMsn.dir/all] Fout 2
make: *** [all] Fout 2
What is wrong?
Re: Program crashes (SIGSEGV)
Quote:
Originally Posted by
Voldemort
What is wrong?
You are missing #include directives.
Re: Program crashes (SIGSEGV)
Do you have a QQMsnApp class at all? Because I see you have QQMsnApplication. Please read and try to understand the errors the compiler tells you. These are pretty straightforward to understand.
Re: Program crashes (SIGSEGV)
Quote:
Originally Posted by
jacek
You are missing #include directives.
I added
Code:
#include <QCoreApplication>
before the define, undef, ...
No difference in errors.
Quote:
Originally Posted by
wysota
Do you have a QQMsnApp class at all? Because I see you have QQMsnApplication. Please read and try to understand the errors the compiler tells you. These are pretty straightforward to understand.
The class its name is QQMsnApplication, but in main.cpp, I do this in main.cpp:
Code:
QQMsnApplication QQMsnApp(argc,argv);
Thats why I use QQMsnApp. Or am I wrong?
Re: Program crashes (SIGSEGV)
Yes, you are wrong. You should use QQMsnApplication in the definition. You put the class in the sharp brackets (<>) to indicate the template class and QCoreApplication::instance() is used to fetch the actual instance of the application. Just copy my definition exactly only changing MyApp* to QQMsnApplication*.
Re: Program crashes (SIGSEGV)
Quote:
/home/quinten/QQMsn_test/src/window_login.cpp: In member function ‘void Window_Login::startLogin()’:
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: ‘QQMsnApp’ was not declared in this scope
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:82: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:83: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:88: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:92: error: expected `)' before ‘;’ token
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected type-specifier before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `>' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `(' before ‘QQMsnApp’
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: ‘QCoreApplication’ has not been declared
/home/quinten/QQMsn_test/src/window_login.cpp:95: error: expected `)' before ‘;’ token
make[2]: *** [CMakeFiles/QQMsn.dir/src/window_login.o] Fout 1
make[1]: *** [CMakeFiles/QQMsn.dir/all] Fout 2
make: *** [all] Fout 2
You must not use QMsnApp.
You redefined qApp but you also have to use it.
qApp is a global pointer to your application's instance ( custom app in this case ).
This means that you can do things like qApp->windowlogin()->show(), etc.
So: make sure you redefined qApp correctly, as wysota pointed. Make sure that in other files, when you want to access QMsnApp, use instead qApp. Again, this is the reason you redefined it in the first place.
And please read this link: qApp.( or look for it in assistant )
This is basic c++ you are asking here. There isn't much related to Qt ( a global pointer is not really Qt-dependent ).
As it is said in other, resemblant posts, telling you how to make it work won't help you understand. Next time you will get these errors again and you won't know what to do.
So, at least try to understand the explanations that are given to you here, and make connections between them.
Regards.
Re: Program crashes (SIGSEGV)
I changed it, but still no difference, the same errors.
definition in header file
Code:
#ifdef qApp
#undef qApp
#endif
#define qApp static_cast<QQMsnApplication*>(QCoreApplication::instance())
use in source file
Code:
//Variablen goed zetten
qApp->cmsn()->setMail(mail->text());
qApp->cmsn()->setPass(pass->text());
//Toon het nieuwe venster (login_busy)
if(!started_login_busy)
{
qApp->login_busy()->show_start();
started_login_busy = true;
}
qApp->login_busy()->show();
//De functie aanroepen die de socket opent en het eerst commando zend
qApp->cmsn()->StartLogin();
main in main.cpp
Code:
int main(int argc, char *argv[])
{
QQMsnApplication QQMsnApplication(argc,argv);
QQMsnApplication.window_login()->show_start();
QQMsnApplication.window_login()->show();
//qDebug() << "Test";
return QQMsnApplication.exec();
}
What goes wrong?
I know I ask basic C++ questions, but I try to learn C++ with Qt. I don't like programming with Konsole windows, I more like to use real windows.
Re: Program crashes (SIGSEGV)
The code is the same regardless where you program. What is stopping you from using graphical editors?
About your question - don't call the variable the same as the class is called.
Change:
Code:
QQMsnApplication QQMsnApplication(argc,argv);
to
Code:
QQMsnApplication app(argc,argv);
Of course all other occurences have to be modified as well.