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
MainWindow
::MainWindow(QWidget *parent
){
...
// get an instance of the globalManager
m_Manager = GlobalManager::GetInstance();
...
}
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), m_ui(new Ui::MainWindowClass)
{
...
// get an instance of the globalManager
m_Manager = GlobalManager::GetInstance();
...
}
To copy to clipboard, switch view to plain text mode
definition of m_Manager
{
Q_OBJECT
public:
~MainWindow();
private:
/// \brief our GlobalManager which controls the rendering - we pass all data to it
GlobalManager *m_Manager;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
/// \brief our GlobalManager which controls the rendering - we pass all data to it
GlobalManager *m_Manager;
};
To copy to clipboard, switch view to plain text mode
The header of the GlobalManager Class
class GlobalManager{
private:
static GlobalManager* m_Instance;
int m_Testvar;
/// \brief private constructor for our manager
GlobalManager();
/// \brief make asssigment operator private
GlobalManager& operator=(GlobalManager&);
/// \brief make copy constructor private
GlobalManager(const GlobalManager&);
public:
static GlobalManager* GetInstance();
void GetRTImage();
};
class GlobalManager{
private:
static GlobalManager* m_Instance;
int m_Testvar;
/// \brief private constructor for our manager
GlobalManager();
/// \brief make asssigment operator private
GlobalManager& operator=(GlobalManager&);
/// \brief make copy constructor private
GlobalManager(const GlobalManager&);
public:
static GlobalManager* GetInstance();
void GetRTImage();
};
To copy to clipboard, switch view to plain text mode
and the according cpp
/// Static memeber initialisation
GlobalManager* GlobalManager::m_Instance = 0;
/// \brief constructor implementation
GlobalManager ::GlobalManager()
{
int m_Testvar = 10;
}
/// \brief function return the only instance of the object
GlobalManager* GlobalManager::GetInstance()
{
if(m_Instance==0)
{
m_Instance=new GlobalManager();
}
return m_Instance;
}
/// Static memeber initialisation
GlobalManager* GlobalManager::m_Instance = 0;
/// \brief constructor implementation
GlobalManager ::GlobalManager()
{
int m_Testvar = 10;
}
/// \brief function return the only instance of the object
GlobalManager* GlobalManager::GetInstance()
{
if(m_Instance==0)
{
m_Instance=new GlobalManager();
}
return m_Instance;
}
To copy to clipboard, switch view to plain text mode
Bookmarks