Qt opengl调试SIGSEGV如何修复

Qt-opengl-debug-SIGSEGV-how to fix?

本文关键字:何修复 SIGSEGV 调试 opengl Qt      更新时间:2023-10-16

我遵循以下教程:https://www.youtube.com/watch?v=1nzHSkY4K18

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

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

2/glwidget.h

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

        #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

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

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

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

4/glwidget.cpp

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

   #include "glwidget.h"
    
    GLWidget::GLWidget(QWidget *parent) :
        QGLWidget(parent)
    {
    }
    
    void GLWidget::initializeGL()
    {
    
    }
    void GLWidget::paintGL()
    {
    
    }
    void GLWidget::resizeGL(int w, int h)
    {
    
    }

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

5/main.cpp

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

   #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }

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

6/主窗口.cpp

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

   #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }

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

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

信号含义:分段故障

这个在Disassembler上??

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

关于";"非法访问存储器"未初始化指针"我该怎么修?我使用Qt5.3.2,明,窗口7 32位。我的屏幕:http://postimg.org/image/pspg5e0g7/

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