Results 1 to 5 of 5

Thread: Subclassiıng QAbstractItemModel for a thread-safe tree model

  1. #1
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question Subclassiıng QAbstractItemModel for a thread-safe tree model

    Hello,
    I needed a thread-safe treemodel, so I intended to subclass QAbstractItemModel for the purpose.
    But I have faced some problems. If any one can help me to overcome them, I will be glad.

    Problems:
    1. some public methods such as index, parent, rowxount, etc. are called by QAbstractItemModel when I called beginInsertRows, etc. So I cannot mutex these functions correctly. (Actually I use QReadWriteLocker)

    2. If I set the model from UI thread the endInsertRows calls treeView's methods directly. (which means treeView's call to Data appears below my insertItem method in the call stack). So the system is locked.

    3. In the index function I am setting (void *) by using createIndex function of QAbstractItemModel, but in one data call an invalid pointer is recieved. Dıes anyone jnows what can cause this.

    Best regards,

  2. #2
    Join Date
    Mar 2007
    Posts
    57
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassiıng QAbstractItemModel for a thread-safe tree model

    I can't really imagine why you would want to use a thread-safe tree model. I don't even know if QAbstractItemModel is thread safe. Wouldn't it be easier to create a thread safe interface to qtreemodel?

  3. #3
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Subclassiıng QAbstractItemModel for a thread-safe tree model

    The problem is;
    I have lots (hundreds per second) of message(each message contains multiple operations on the model) coming from network, and need to write them in more than 30 models When I do it on UI main thread therfe occurs a freezing problem on GUI.
    And even this doesnot guarentee that the view will not request an invalid index. So I required a thread-safe model if possible.

    By the way QAbstactItemModel is not thread-safe.

    regards,

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

    Default Re: Subclassiıng QAbstractItemModel for a thread-safe tree model

    so there isnt actually any usefull reply?

    i have a similar situation..
    I find that using a model to centralize the data-handling is of little use if, when i really need to centralize the handling of data (ie network operations or other clients) the model can't do it.

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

    Default Re: Subclassiıng QAbstractItemModel for a thread-safe tree model

    And where are threads in all this?
    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.


Similar Threads

  1. Thread Safe Queue container....
    By jcox23 in forum Newbie
    Replies: 25
    Last Post: 5th June 2012, 19:36
  2. About the QSound,is thread safe?
    By cspp in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2009, 14:26
  3. Is a QProcess thread safe in Qt4?
    By Jay_D in forum Qt Programming
    Replies: 4
    Last Post: 1st September 2009, 16:38
  4. What makes something not thread safe?
    By tgreaves in forum Newbie
    Replies: 9
    Last Post: 20th February 2009, 20:16
  5. Replies: 1
    Last Post: 6th July 2007, 12:16

Tags for this Thread

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.