Does anyone has a short example (hopefully in C++) to illustrate adding a QTreeView to a QDockWidget?
I tried to use QLayout as an intermediate object, as:
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel model(file.readAll());
file.close();
QTreeView w;
w.setModel(&model);
w.setWindowTitle(QObject::tr("Simple Tree Model"));
QGridLayout *layout;
layout = new QGridLayout;
layout->addWidget(&w, 0, 0, 1, 3);
swatch1->setLayout(layout);
Where swatch1 is of a type from QDockWidget. my code runs, but the tree does not appear on the DockWidget.
I saw QTreeWidget examples, but since the tree view will be changed frequently, I prefer to use a QTreeView.
Does anyone can provide a short example on how to put QTreeView onto QDockWidget? Thanks