Page 3 of 3 FirstFirst 123
Results 41 to 48 of 48

Thread: Program crashes (SIGSEGV)

  1. #41
    Join Date
    May 2007
    Posts
    37
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Program crashes (SIGSEGV)

    I've changed that, but I have changed the QQMsnApplication class (there were errors):

    Qt Code:
    1. debugger* QQMsnApplication::debug()
    2. {
    3. return m_debug;
    4. }
    5.  
    6. cmsn* QQMsnApplication::msn()
    7. {
    8. return m_msn;
    9. }
    10.  
    11. Window_Login* QQMsnApplication::window_login()
    12. {
    13. return m_window_login;
    14. }
    15.  
    16. Window_Login_Busy* QQMsnApplication::login_busy()
    17. {
    18. return m_login_busy;
    19. }
    To copy to clipboard, switch view to plain text mode 
    But as I said, I still get errors, these are:

    /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?
    Using Qt version 4.3.0

  2. #42
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes (SIGSEGV)

    Quote Originally Posted by Voldemort View Post
    What is wrong?
    You are missing #include directives.

  3. #43
    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: 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.

  4. #44
    Join Date
    May 2007
    Posts
    37
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Program crashes (SIGSEGV)

    Quote Originally Posted by jacek View Post
    You are missing #include directives.
    I added

    Qt Code:
    1. #include <QCoreApplication>
    To copy to clipboard, switch view to plain text mode 

    before the define, undef, ...

    No difference in errors.

    Quote Originally Posted by wysota View Post
    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:

    Qt Code:
    1. QQMsnApplication QQMsnApp(argc,argv);
    To copy to clipboard, switch view to plain text mode 

    Thats why I use QQMsnApp. Or am I wrong?
    Using Qt version 4.3.0

  5. #45
    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: 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*.

  6. #46
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Program crashes (SIGSEGV)

    /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.

  7. #47
    Join Date
    May 2007
    Posts
    37
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Program crashes (SIGSEGV)

    I changed it, but still no difference, the same errors.

    definition in header file
    Qt Code:
    1. #ifdef qApp
    2. #undef qApp
    3. #endif
    4. #define qApp static_cast<QQMsnApplication*>(QCoreApplication::instance())
    To copy to clipboard, switch view to plain text mode 


    use in source file
    Qt Code:
    1. //Variablen goed zetten
    2. qApp->cmsn()->setMail(mail->text());
    3. qApp->cmsn()->setPass(pass->text());
    4.  
    5. //Toon het nieuwe venster (login_busy)
    6. if(!started_login_busy)
    7. {
    8. qApp->login_busy()->show_start();
    9. started_login_busy = true;
    10. }
    11.  
    12. qApp->login_busy()->show();
    13.  
    14. //De functie aanroepen die de socket opent en het eerst commando zend
    15. qApp->cmsn()->StartLogin();
    To copy to clipboard, switch view to plain text mode 


    main in main.cpp

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QQMsnApplication QQMsnApplication(argc,argv);
    4.  
    5. QQMsnApplication.window_login()->show_start();
    6. QQMsnApplication.window_login()->show();
    7.  
    8. //qDebug() << "Test";
    9.  
    10. return QQMsnApplication.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Using Qt version 4.3.0

  8. #48
    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: 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:
    Qt Code:
    1. QQMsnApplication QQMsnApplication(argc,argv);
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. QQMsnApplication app(argc,argv);
    To copy to clipboard, switch view to plain text mode 

    Of course all other occurences have to be modified as well.

Similar Threads

  1. Porting my program to another windows machine !
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 07:46
  2. QT Program debug,GDB on Linux
    By darpan in forum General Programming
    Replies: 1
    Last Post: 26th January 2007, 23:02
  3. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 05:19
  4. Enter key causing program to exit
    By welby in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 17:11
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 20:32

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.