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. SIGSEGV on QTabWidget::close
QtWS25 Last Chance

SIGSEGV on QTabWidget::close

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 942 Views
  • 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.
  • pauleddP Offline
    pauleddP Offline
    pauledd
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      1
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        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
        0
        • pauleddP Offline
          pauleddP Offline
          pauledd
          wrote on last edited by pauledd
          #4

          @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
          0
          • pauleddP Offline
            pauleddP Offline
            pauledd
            wrote on last edited by
            #5

            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
            0
            • pauleddP Offline
              pauleddP Offline
              pauledd
              wrote on last edited by pauledd
              #6

              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
              0
              • pauleddP Offline
                pauleddP Offline
                pauledd
                wrote on last edited by
                #7

                Solved my removing all addSpacerItems.

                1 Reply Last reply
                0

                • Login

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