1 Attachment(s)
Problem with updating QTreeView with QAbstractITemModel
Hi everyone,
I am working on the "Simple Tree Model" example. https://het.as.utexas.edu/HET/Softwa...treemodel.html
However, the data in my QTreeView is not being updated.
If somebody can tell that where I am making a mistake that would be great?
Code:
#include <QMainWindow>
#include <QtGui>
#include <QTreeView>
#include "treemodel.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) , ui(new Ui::MainWindow)
{
ui->setupUi(this);
QFile file("/hdd2/users/mohsinali/Inc_Training_Utility/0.sampleFiles/Default.txt");
TreeModel model(file.readAll());
file.close();
ui->treeView->setModel(&model);
ui->treeView->setWindowTitle("Simple Tree Model");
setCentralWidget(ui->treeView);
}
Attachment 13632
Re: Problem with updating QTreeView with QAbstractITemModel
Line 15 - think about what happens to this variable that you create on the stack when the MainWindow constructor exits.