rbrand
4th July 2006, 08:34
Hi,
I'm new with Qt and Icustomize the simpletreemodel example. I would like to display the model also in a tableview. In the tableview only the treeItems on the first level (parent=root) are displayed. Selecting a treeItem in another level in the tableview nothing changes. Is this behaviour correct ?
R. Brand
Here is my main-routine
#include <QtGui>
#include "ui_treetable.h"
#include "treemodel.h"
#include <QFile>
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(simpletreemodel);
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(true);
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel model(file.readAll());
file.close();
QItemSelectionModel *selectionmodel;
QMainWindow *form = new QMainWindow;
Ui::MainWindow ui;
ui.setupUi(form);
ui.treeView->setModel(&model);
ui.tableView->setModel(&model);
selectionmodel = ui.treeView->selectionModel();
ui.tableView->setSelectionModel(selectionmodel);
form->show();
return app.exec();
}
I'm new with Qt and Icustomize the simpletreemodel example. I would like to display the model also in a tableview. In the tableview only the treeItems on the first level (parent=root) are displayed. Selecting a treeItem in another level in the tableview nothing changes. Is this behaviour correct ?
R. Brand
Here is my main-routine
#include <QtGui>
#include "ui_treetable.h"
#include "treemodel.h"
#include <QFile>
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(simpletreemodel);
QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(true);
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel model(file.readAll());
file.close();
QItemSelectionModel *selectionmodel;
QMainWindow *form = new QMainWindow;
Ui::MainWindow ui;
ui.setupUi(form);
ui.treeView->setModel(&model);
ui.tableView->setModel(&model);
selectionmodel = ui.treeView->selectionModel();
ui.tableView->setSelectionModel(selectionmodel);
form->show();
return app.exec();
}