Results 1 to 4 of 4

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

  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

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

    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:n_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);
    }

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: ASSERT: "index.model() == q" in file dialogs\qfilesystemmodel.cpp, line 1278

    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.

  3. The following user says thank you to ChrisW67 for this useful post:

    Divad (13th January 2014)

  4. #3
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ASSERT: "index.model() == q" in file dialogs\qfilesystemmodel.cpp, line 1278

    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

    Qt Code:
    1. void TreeView::contextMenuEvent(QContextMenuEvent *event)
    2. {
    3. QModelIndex index = indexAt(event->pos()); //this->currentIndex();
    4. QFileSystemModel mod;
    5. qDebug() << index.isValid();
    6. qDebug() << mod.fileName(index);
    7. qDebug() << mod.filePath(index);
    8. }
    To copy to clipboard, switch view to plain text mode 

    Any ideas?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: ASSERT: "index.model() == q" in file dialogs\qfilesystemmodel.cpp, line 1278

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    JayZ (26th September 2012)

Similar Threads

  1. ASSERT: "bitmap" in file image\qnativeimage.cpp, line 114
    By DusanDusan in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2012, 06:30
  2. Replies: 1
    Last Post: 5th February 2011, 21:14
  3. Replies: 3
    Last Post: 15th February 2010, 17:27
  4. Replies: 3
    Last Post: 8th July 2008, 19:37
  5. Replies: 1
    Last Post: 10th March 2008, 17:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.