Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. terminated by signal SIGSEGV (Address boundary error)
Qt 6.11 is out! See what's new in the release blog

terminated by signal SIGSEGV (Address boundary error)

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 13character51 Offline
    13character51 Offline
    13character5
    wrote on last edited by
    #1

    Newbie to Qt/C++ here. My code builds successfully but when I run my newly compiled application, I get an address boundary error. what part of my code is causing it?

    // main.cpp
    #include "mainwindow.h"
    
    #include <QApplication>
    #include <QLocale>
    #include <QTranslator>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QTranslator translator;
        const QStringList uiLanguages = QLocale::system().uiLanguages();
        for (const QString &locale : uiLanguages) {
            const QString baseName = "Hello_Qt_" + QLocale(locale).name();
            if (translator.load(":/i18n/" + baseName)) {
                a.installTranslator(&translator);
                break;
            }
        }
        MainWindow mainWindow;
        mainWindow.show();
        return a.exec();
    }
    
    // mainwindow.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QPushButton>
    
    QT_BEGIN_NAMESPACE
    namespace Ui {
    class MainWindow;
    }
    QT_END_NAMESPACE
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    private slots:
        void handleButton();
    private:
        QPushButton *pressMeButton;
        Ui::MainWindow *ui;
    };
    #endif
    
    // mainwindow.cpp
    #include "mainwindow.h"
    #include "./ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        connect(pressMeButton, &QPushButton::released, this, &MainWindow::handleButton);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::handleButton()
    {
    
    }
    
    1 Reply Last reply
    0
    • Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @13character5
      Debug your program and check where it crashes


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • 13character51 Offline
        13character51 Offline
        13character5
        wrote on last edited by 13character5
        #3

        how do I debug with QtCreator?

        Pl45m4P 1 Reply Last reply
        0
        • 13character51 13character5

          how do I debug with QtCreator?

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @13character5

          Run a debugger (F5) and step through your app until you face the crash. It will stop and show the last call

          Edit:

          You don't actually create your button in your constructor. You just declared the variable and tried to connect to it. At this point, there is no pushbutton then.

          Instantiate your QPushButton and it should work.
          (AFAICS this might be the cause of your crash, unless there is something else somewhere in your code that you are not showing)


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          2
          • 13character51 Offline
            13character51 Offline
            13character5
            wrote on last edited by
            #5

            how do i Instantiate a QPushButton

            Christian EhrlicherC JonBJ 2 Replies Last reply
            0
            • 13character51 13character5

              how do i Instantiate a QPushButton

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @13character5 said in terminated by signal SIGSEGV (Address boundary error):

              how do i Instantiate a QPushButton

              You should learn C++ before trying Qt: https://www.geeksforgeeks.org/cpp/c-classes-and-objects/

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              2
              • 13character51 13character5

                how do i Instantiate a QPushButton

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @13character5
                As the others have said. But since you seem to have used Qt Designer to design some interface (right?) I suspect/wonder whether you are trying to access a QPushButton which you already put there? Perhaps named by you at the time pressMeButton? If so it will be inside the ui object, like ui->pressMeButton. And you won't want/need your own (currently uninitialized, hence the crash) QPushButton *pressMeButton as a class variable?

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved