Results 1 to 2 of 2

Thread: Application crashes after adding a new class

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

    Default Application crashes after adding a new class

    Hi

    I'm trying to implement an OpenGL application with Qt. As a starting point I used an example I found on the web (http://blog.lugru.com/2009/03/qtdesigner-and-qglwidget/)

    But always when I try to extend the functions by adding a new class my application crashs before startup. It crashes always somewhere in the Events part of the Qt libraries

    here the code how i coneted my class with the existing parts.

    Thanks in advance for any help

    mainwindow constructor
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), m_ui(new Ui::MainWindowClass)
    3. {
    4. ...
    5. // get an instance of the globalManager
    6. m_Manager = GlobalManager::GetInstance();
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 


    definition of m_Manager
    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MainWindow(QWidget *parent = 0);
    7. ~MainWindow();
    8.  
    9. private:
    10. /// \brief our GlobalManager which controls the rendering - we pass all data to it
    11. GlobalManager *m_Manager;
    12.  
    13. };
    To copy to clipboard, switch view to plain text mode 


    The header of the GlobalManager Class

    Qt Code:
    1. class GlobalManager{
    2. private:
    3. static GlobalManager* m_Instance;
    4.  
    5. int m_Testvar;
    6.  
    7. /// \brief private constructor for our manager
    8. GlobalManager();
    9. /// \brief make asssigment operator private
    10. GlobalManager& operator=(GlobalManager&);
    11. /// \brief make copy constructor private
    12. GlobalManager(const GlobalManager&);
    13.  
    14. public:
    15. static GlobalManager* GetInstance();
    16. void GetRTImage();
    17.  
    18. };
    To copy to clipboard, switch view to plain text mode 
    and the according cpp
    Qt Code:
    1. /// Static memeber initialisation
    2. GlobalManager* GlobalManager::m_Instance = 0;
    3.  
    4. /// \brief constructor implementation
    5. GlobalManager ::GlobalManager()
    6. {
    7. int m_Testvar = 10;
    8. }
    9.  
    10. /// \brief function return the only instance of the object
    11. GlobalManager* GlobalManager::GetInstance()
    12. {
    13. if(m_Instance==0)
    14. {
    15. m_Instance=new GlobalManager();
    16. }
    17. return m_Instance;
    18. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: Application crashes after adding a new class

    Can you send a backtrace of your debugger. And are you sure using m_Manager only after your posted line in the c-tor?

Similar Threads

  1. Application crashes when it has a particular name
    By hunsrus in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2010, 21:50
  2. Application crashes
    By waynew in forum Newbie
    Replies: 1
    Last Post: 2nd November 2009, 11:31
  3. QtStyles and Application Crashes
    By vladozar in forum Qt Programming
    Replies: 0
    Last Post: 19th September 2009, 15:59
  4. My application crashes
    By sophister in forum Qt Programming
    Replies: 13
    Last Post: 27th April 2009, 08:39
  5. Application crashes at launch-time
    By Salazaar in forum Newbie
    Replies: 70
    Last Post: 22nd June 2007, 02:11

Tags for this Thread

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.