Results 1 to 5 of 5

Thread: segfault when accessing QObjetcList based Listmodel in qml..

  1. #1
    Join Date
    Aug 2011
    Posts
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default segfault when accessing QObjetcList based Listmodel in qml..

    I do have QObject based Listmodel in QML listview. Like
    Qt Code:
    1. QList<QObject*> dataList;
    To copy to clipboard, switch view to plain text mode 

    Problem is that when I reopen the view my program will get segfault in the QObject first property accesss.

    - Open view and fill view without problem
    - But second turn segfault occur before QML views Component.onCompleted signal.

    Debug mode show that QObject first call to object property will get crash but no debug print shown at C++ side.

    I will the Loader patten to load and switch between different views.

    How I will reset my view ?

    Qt 4.8 at Ubuntu

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: segfault when accessing QObjetcList based Listmodel in qml..

    how is your model implemented and referenced in qml ?
    we need more info to see the real problem here

  3. #3
    Join Date
    Aug 2011
    Posts
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: segfault when accessing QObjetcList based Listmodel in qml..

    qml:

    ListView {
    .
    .
    .

    width: parent.width - 50; height: parent.height - upptoolbar.height
    model: c_listModel
    z: 0
    delegate: ViewDelegate {}
    highlight: Rectangle
    { color: "lightsteelblue"; radius: 5
    width: rssview.width - 20
    x: 10}

    and
    c++
    app->declarativeEngine()->rootContext()->setContextProperty("c_listModel", QVariant::fromValue(m_list));

    and

    QList<QObject*> m_list;

  4. #4
    Join Date
    Aug 2011
    Posts
    38
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: segfault when accessing QObjetcList based Listmodel in qml..

    Problem root cause located, i will make more investagations and study.

    Problem is how is data returned

  5. #5
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: segfault when accessing QObjetcList based Listmodel in qml..

    A list model is not a QList per se, but something that inherits from QAbstractListModel. Once you have a reference to such a model, you pass it as the second parameter to setContextProperty(). To access the data in the model, use functions like data(), itemData(), findX(), and so on.

Similar Threads

  1. Replies: 1
    Last Post: 6th August 2012, 16:48
  2. Replies: 0
    Last Post: 27th March 2012, 08:51
  3. QML ListModel for interaction with C++
    By shock in forum Qt Quick
    Replies: 23
    Last Post: 21st March 2012, 23:42
  4. ListModel.remove() crashes program
    By truefusion in forum Qt Quick
    Replies: 5
    Last Post: 5th February 2012, 15:27
  5. A simplest ListModel... no example :(
    By tomek in forum Newbie
    Replies: 5
    Last Post: 7th January 2006, 00:32

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.