C++ (Qt)MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); root = new QObject(this); treeview = new TreeView(this); treemodel = new TreeModelBrowser(root); treeview->setModel(treemodel); }
C++ (Qt)void TreeView::actWscan(){ wps = new widgetScan() wps->show(); } TreeView::~TreeView(){ qDebug()<<"Delete TreeView"; if(wscan != NULL) { wscan->close(); wscan = NULL; }}
C++ (Qt)widgetScan::widgetScan(QWidget *parent): QWidget(parent){ setAttribute(Qt::WA_DeleteOnClose);}
C++ (Qt)#include "mainwindow.h"#include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); newWidow = NULL; connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(addNewWindow())); setAttribute(Qt::WA_DeleteOnClose);} MainWindow::~MainWindow(){ delete ui; if(newWidow != NULL) { newWidow->close(); delete newWidow; newWidow = NULL; }} void MainWindow::addNewWindow(){ if(newWidow == NULL) { newWidow = new MyWidget; connect(newWidow,SIGNAL(closeMyWidget()),this,SLOT(nullNewWindow())); newWidow->show(); }} void MainWindow::nullNewWindow(){ newWidow = NULL;}
C++ (Qt)MyWidget::MyWidget(QWidget *parent): QWidget(parent){ setAttribute(Qt::WA_DeleteOnClose);} MyWidget::~MyWidget(){ Q_EMIT closeMyWidget();}
Okna-build-desktop\debug\Okna.exe завершился с кодом -1073741819
C++ (Qt)Qapplication app;MainWindow w;w.show();return app.exec();