Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Qt opengl调试SIGSEGV如何修复?_C++_Qt_Opengl - Fatal编程技术网

C++ Qt opengl调试SIGSEGV如何修复?

C++ Qt opengl调试SIGSEGV如何修复?,c++,qt,opengl,C++,Qt,Opengl,我将遵循以下教程: 1/test_opengl.pro ============================================== QT += core gui opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = test_opengl TEMPLATE = app

我将遵循以下教程:

1/test_opengl.pro

==============================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
2/glwidget.h

================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
============================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
5/main.cpp

============================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
============================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
7/mainwindow.ui

============================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>

主窗口
Qt::ApplicationModel
0
0
555
365
0
0
Opengl
0
0
Qt::垂直
20
40
&;退出
GLWidget
QWidget
glwidget.h
1.
按钮
点击()
主窗口
关闭()
383
342
390
230
============================================================

        QT       += core gui opengl
        
        greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
        
        TARGET = test_opengl
        TEMPLATE = app
        
        
        SOURCES += main.cpp\
                mainwindow.cpp \
            glwidget.cpp
        
        HEADERS  += mainwindow.h \
            glwidget.h
        
        FORMS    += mainwindow.ui
        #ifndef GLWIDGET_H
        #define GLWIDGET_H
        
        #include <QGLWidget>
        
        class GLWidget : public QGLWidget
        {
            Q_OBJECT
        public:
            explicit GLWidget(QWidget *parent = 0);
        
            void initializeGL();
            void paintGL();
            void resizeGL(int w, int h);
        };
        
        #endif // GLWIDGET_H
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }
   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
            <?xml version="1.0" encoding="UTF-8"?>
        <ui version="4.0">
         <class>MainWindow</class>
         <widget class="QMainWindow" name="MainWindow">
          <property name="windowModality">
           <enum>Qt::ApplicationModal</enum>
          </property>
          <property name="geometry">
           <rect>
            <x>0</x>
            <y>0</y>
            <width>555</width>
            <height>365</height>
           </rect>
          </property>
          <property name="sizePolicy">
           <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="windowTitle">
           <string>Opengl</string>
          </property>
          <widget class="QWidget" name="centralWidget">
           <layout class="QHBoxLayout" name="horizontalLayout">
            <item>
             <widget class="GLWidget" name="widget" native="true">
              <property name="sizePolicy">
               <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
                <horstretch>0</horstretch>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
             </widget>
            </item>
            <item>
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <spacer name="verticalSpacer">
                <property name="orientation">
                 <enum>Qt::Vertical</enum>
                </property>
                <property name="sizeHint" stdset="0">
                 <size>
                  <width>20</width>
                  <height>40</height>
                 </size>
                </property>
               </spacer>
              </item>
              <item>
               <widget class="QPushButton" name="pushButton">
                <property name="text">
                 <string>&amp;Quit</string>
                </property>
               </widget>
              </item>
             </layout>
            </item>
           </layout>
          </widget>
         </widget>
         <layoutdefault spacing="6" margin="11"/>
         <customwidgets>
          <customwidget>
           <class>GLWidget</class>
           <extends>QWidget</extends>
           <header>glwidget.h</header>
           <container>1</container>
          </customwidget>
         </customwidgets>
         <resources/>
         <connections>
          <connection>
           <sender>pushButton</sender>
           <signal>clicked()</signal>
           <receiver>MainWindow</receiver>
           <slot>close()</slot>
           <hints>
            <hint type="sourcelabel">
             <x>383</x>
             <y>342</y>
            </hint>
            <hint type="destinationlabel">
             <x>390</x>
             <y>230</y>
            </hint>
           </hints>
          </connection>
         </connections>
        </ui>
调试时,我得到:

由于收到来自操作系统的信号,下位机停止

信号名称:SIGSEGV

信号含义:分段故障

这是反汇编程序吗

0x143d1fa6--------83 80 40 01 00 00 ff--------addl------$0xffffffff,0x140(%eax)

“非法访问内存”、“未初始化指针”有问题吗?我怎样才能修好它?
我使用Qt5.3.2,mingw,windows7 32位。我的屏幕:

我认为我的驱动程序有问题,我尝试删除并设置了Qt,但较旧的版本(Qt 4.8.6)并已运行。

是否存在堆栈帧或至少模块崩溃?因为我不能重现那个错误,我不知道。如何找到该模块并修复它?请查看调试窗口中的模块和堆栈帧。通过查看地址(例如,查找两个0x143d1fa6之间的地址)0??C:\Windows\system32\ig4icd32.dll 0x143d1fa6 1??0xababababab是您的英特尔OpenGL驱动程序,您可以看到它是哪个模块。您能在调用堆栈中看到调用它的内容吗(很可能是GLWidget,但是哪个函数)?