Results 1 to 4 of 4

Thread: Modifying QStandardItemModel from non-UI QThread?

  1. #1
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Modifying QStandardItemModel from non-UI QThread?

    Hi,

    I have Qt4 app which binds QStandardItemModel to the QListView and have the model updated from background/non-UI thread.

    Sometimes, when the QStandardItem's setText(..) method is called very repeatedly from the non-UI thread, the application will crash at data_changed(..) handler. I can reproduce the issue by calling setText("xxxxx") repeatedly in a loop. In my app, the data is read from network hence I update the model in separate, non-UI thread.

    Is this a common pb? Having search the forums but couldn't find sth similar ...

    Thanks!

  2. #2
    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: Modifying QStandardItemModel from non-UI QThread?

    You cannot directly interact with QStandardItemModel from a worker thread.
    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.


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

    m3rlinez (11th December 2010)

  4. #3
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Modifying QStandardItemModel from non-UI QThread?

    @wysota Thanks for confirming this! Looks like I will have to go with slot + signal to update QStandardItemModel from GUI thread .. Just imagine it would be nice if we have a thread-safe version (:

  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: Modifying QStandardItemModel from non-UI QThread?

    Quote Originally Posted by m3rlinez View Post
    Just imagine it would be nice if we have a thread-safe version (:
    The whole Qt would probably become much much slower then.
    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. Modifying file with Qt
    By afail in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2009, 14:34
  2. Modifying QListView items
    By Daniel Salcedo in forum Qt Programming
    Replies: 0
    Last Post: 14th September 2009, 15:59
  3. Modifying a text
    By jaca in forum Qt Programming
    Replies: 3
    Last Post: 6th May 2008, 15:50
  4. Modifying a line in a QTextEdit
    By elcuco in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2008, 16:50
  5. Modifying Dialog problem
    By donmorr in forum Qt Tools
    Replies: 5
    Last Post: 26th May 2006, 12:56

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.