Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved SIGSEGV on QTabWidget::close

    General and Desktop
    3
    7
    599
    Loading More Posts
    • 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.
    • pauledd
      pauledd last edited by

      Hi there,

      I have a problem with proper closing my application without a SIGSEGV.

      My window is made of a QTabWidget derived widget. The tabwidget
      has four tabs and each has an ordinary qwidget in it.

      class TabWidget : public QTabWidget
      {
          Q_OBJECT
      public:
          explicit TabWidget(QTabWidget *parent = Q_NULLPTR);
      

      In one of the tabs qwidget I have a pushbutton that is connected to the tabwidgets
      close() function.

      connect(pbExit,&QPushButton::clicked,this,&TabWidget::close);
      

      If I press the button (or click on the close window cross) the application quits with SIGSEGV:

      The program has unexpectedly finished.
      The process was ended forcefully.
      /home/paul/store/c++/qt/build-qt-wetter-0.7-Desktop-Debug/qt-wetter-0 crashed.
      

      If I debug the app it shows me the arrow where the error might be but the arrow is pointing at the Tabwidget class declaration itself, how could I debug further to find the problem?

      0_1531129363060_Bildschirmfoto_2018-07-09_11-42-29.png

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Do you have any of your widgets on the stack and giving it a parent at the same time ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • VRonin
          VRonin last edited by

          An other possibility is you having set the Qt::WA_DeleteOnClose attribute

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply Reply Quote 0
          • pauledd
            pauledd last edited by pauledd

            @VRonin I indeed set that flag attribute, just to see if that changes something but removing it does not solve it.

            @SGaist no, the widgets I use for the tabs do not have a parent,

            tab1 = new QWidget;
            tab2 = new QWidget;
            tab3 = new QWidget;
            tab4 = new QWidget;
            this->addTab(tab1,"Sensoren");
            this->addTab(tab2,"Regenradar");
            this->addTab(tab3, "Graph");
            this->addTab(tab4, "System");
            

            I will try to comment out parts of my code to condense the problem

            1 Reply Last reply Reply Quote 0
            • pauledd
              pauledd last edited by

              Okay I am getting closer, I found a line in the TabWidget constructor where I add a QHBoxLayout to a VBoxLayout (addLayout)... that causes the trouble. Trying to fix that :)

              1 Reply Last reply Reply Quote 0
              • pauledd
                pauledd last edited by pauledd

                That faulty QHBoxLayout has the problem that I added a QSpacerItem (addSpacerItem) to it two times... So I guess that is not the right way to use QSpacerItem? Can it only be added once to a QHBoxLayout?

                EDIT:
                Normally, you don't need to use this class directly. Qt's built-in layout managers provide the following functions for manipulating empty space in layouts

                http://doc.qt.io/archives/qt-4.8/qspaceritem.html

                1 Reply Last reply Reply Quote 0
                • pauledd
                  pauledd last edited by

                  Solved my removing all addSpacerItems.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post