MainWindow.h
Qt Code:
  1. #include <QMainWindow>
  2.  
  3. class MainWindow : public QMainWindow
  4. {
  5. Q_OBJECT
  6. public:
  7. explicit MainWindow(QWidget *parent = 0);
  8. };
To copy to clipboard, switch view to plain text mode 

MainWindow.cpp
Qt Code:
  1. #include "MainWindow.h"
  2.  
  3. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
  4. {
  5. #ifdef QT_DEBUG
  6. setWindowTitle("DEBUG");
  7. #else
  8. setWindowTitle("RELEASE");
  9. #endif
  10.  
  11. }
To copy to clipboard, switch view to plain text mode 

Application.h
Qt Code:
  1. #include <QApplication>
  2.  
  3. class MainWindow;
  4.  
  5. class Application : public QApplication
  6. {
  7. public:
  8. Application(int argc, char** argv);
  9. ~Application();
  10. MainWindow* mainWindow() const;
  11. private:
  12. MainWindow* _mainWindow;
  13. };
To copy to clipboard, switch view to plain text mode 
Application.cpp
Qt Code:
  1. #include "Application.h"
  2. #include "MainWindow.h"
  3.  
  4. Application::Application(int argc, char** argv) : QApplication(argc, argv)
  5. {
  6. _mainWindow = new MainWindow;
  7. }
  8.  
  9. Application::~Application(){
  10. delete _mainWindow;
  11. _mainWindow = 0;
  12. }
  13.  
  14. MainWindow * Application::mainWindow() const
  15. {
  16. return _mainWindow;
  17. }
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include "Application.h"
  2. #include "MainWindow.h"
  3.  
  4. int main(int argc, char** argv)
  5. {
  6. Application app(argc, argv);
  7. app.mainWindow()->show();
  8. return app.exec();
  9. }
To copy to clipboard, switch view to plain text mode 


The code above run perfectly fine under release build, but will cause SIGSEGV Error everytime under debug build.
My system is Ubuntu 11.04 64-bits, Qt 4.8/4.7.4