Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTabWidget close program when i change tab



  • Hi

    My problem is that when I start the program and immediately wants to change the tab, the program closes when I do something on the first tab and then change to the next one everything is fine.

    Its code when i create tabwidget:

    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow),
          mTabWidget(new QTabWidget(this)),
          mSummaryPaymentWidget(new SummaryPaymentWidget(this)),
          mCategoryWidget(new CategoryWidget(this)),
          mStackedWidget(new QStackedWidget(this))
    {
        ui->setupUi(this);
    
        SummaryPaymentModel *model = new SummaryPaymentModel(this);
    
        mSummaryPaymentWidget->setModel(model);
    
        CategoryModel *categoryModel = new CategoryModel(this);
    
        mCategoryWidget->setModel(categoryModel);
    
        mTabWidget->setUpdatesEnabled(false);
        mTabWidget->addTab(mSummaryPaymentWidget, tr("Podsuwoanie wydaktów"));
        mTabWidget->addTab(mCategoryWidget, tr("Kategorie"));
        mTabWidget->setUpdatesEnabled(true);
    
        //mStackedWidget->addWidget(mTabWidget);
    
    
        //setCentralWidget(mStackedWidget);
    
        setCentralWidget(mTabWidget);
    }
    

  • Lifetime Qt Champion

    @ppitu So, did you at least use debugger to see where it crashes (I assume it crashes) and to get stack trace after crash?


Log in to reply