
Originally Posted by
viulskiez
The source code doesn't clear because you do not use new operator to instantiate the object, but you try to destroy using delete operator.
Yes, it's my mistake. The source should be:
MainWindow::MainWindow()
{
m_pView = new QDeclarativeView(); // CONSTRUCT NEW QtDeclarativeView
m_pView->setSource("qrc:/UI/main.qml");
setCentralWidget(m_pView);
setFocus();
centralWidget()->setFocus();
}
MainWindow::MainWindow()
{
m_pView = new QDeclarativeView(); // CONSTRUCT NEW QtDeclarativeView
m_pView->setSource("qrc:/UI/main.qml");
setCentralWidget(m_pView);
setFocus();
centralWidget()->setFocus();
}
To copy to clipboard, switch view to plain text mode
But I can't not delete QDeclarativeView* after using new operator.
It's ok to continue the program without delete, but it can lead to memory leaking. How to avoid it
Bookmarks