PDA

View Full Version : ASSERT: "index.model() == q" in file dialogs\qfilesystemmodel.cpp, line 1278



narlapavan
7th August 2012, 07:23
I did this project in ubuntu 12.04 their it's working fine and i brought this code to windows and compiled it's giving assertion AT model->filepath(index) when double clicking on treeview

void DataMgr::on_treeView_doubleClicked(const QModelIndex &index)
{
QFileSystemModel *model = new QFileSystemModel;
QString strFilePath = model->filePath(index);
---------------- GETTING ASSERTION WHILE USING model->filepath(index) WHY? WHEN I AM USING model->filename(index) it's not giving any error
qDebug()<<strFilePath;
QFileInfo fileinfo(strFilePath);
}

ChrisW67
7th August 2012, 07:33
The index you are using in the call is an index from a different model: it must be because the model you are calling the method on does not exist until you enter this function.

JayZ
26th September 2012, 18:38
Hi! I have exactly the same problem. My code works fine under cygwin, but crashes with the same assertion under windows. The index I receive from indexAt() or currentIndex() is valid, I can call fileName(), but when I call filePath() I get the following assertion:

ASSERT: "index.model() == q" in file dialogs/qfilesystemmodel.cpp, line 1301



void TreeView::contextMenuEvent(QContextMenuEvent *event)
{
QModelIndex index = indexAt(event->pos()); //this->currentIndex();
QFileSystemModel mod;
qDebug() << index.isValid();
qDebug() << mod.fileName(index);
qDebug() << mod.filePath(index);
}


Any ideas?

wysota
26th September 2012, 21:21
You are creating a local instance of the model thus the index you get is not from the model you are trying to pass it to.