[Qt-interest] Question on QAbstractItemView::setModel
Mathieu Malaterre
mathieu.malaterre at gmail.com
Thu Dec 30 17:08:14 CET 2010
Hi there,
I am discovering Qt, and in particular QtCreator. I created a simple
GUI with a single TreeView (Model-Based) and I am trying to update
it's content. Following instructions from:
http://doc.trolltech.com/4.5/itemviews-simpletreemodel.html
I have added the different files to the project. However when I
connect (using a slot) I cannot get anything to appear on the
TreeView. I tried adding a simple:
...
ui->label->setText( "hello");
...
within my slot and it does appear as expected. So in short:
- My push button trigger the event (I can see the string 'hello'
appearing in textlabel object)
- my project compile and run
- I copy directly the source code from:
qt4-x11-4.7.1/examples/itemviews/simpletreemodel
My slot's code is:
void MainWindow::slot1()
{
QFile file("/tmp/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel model(file.readAll());
file.close();
ui->treeView->setModel(&model);
ui->treeView->update();
// update a text label just to check:
ui->label->setText( "coucou");
}
Any suggestion welcome !
--
Mathieu
More information about the Qt-interest-old
mailing list