Results 1 to 4 of 4

Thread: graphics scene

  1. #1
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default graphics scene

    why i can not call add item from other thread?
    it give warning:

    QObject::startTimer: timers cannot be started from another thread
    QObject::killTimer: timers cannot be stopped from another thread

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: graphics scene

    How are you calling the timers ?
    QGraphicsItem IS NOT inherited by QObject !

  3. #3
    Join Date
    May 2009
    Posts
    38
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: graphics scene

    Quote Originally Posted by aamer4yu View Post
    How are you calling the timers ?
    QGraphicsItem IS NOT inherited by QObject !
    QObject::starttimer(40);

    I am not create the timer inside of Item

    any expert to explain why I get warning when I call addItem from other thread

  4. #4
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: graphics scene

    Qt Help tells us:

    QObject and all of its subclasses are not thread-safe. This includes the entire event delivery system. It is important to keep in mind that the event loop may be delivering events to your QObject subclass while you are accessing the object from another thread.
    In your case QGraphicsScene::addItem must be called from the main thread. This is necessary because addItem may post events (e.g. for updating the views). The warning appears because the current implementation of QGraphicsScene::addItem starts a timer to do some indexing.

    In other words: Manipulate GUI objects only in the main thread.

    Use a queued connection to notify you scene that it should add an item.

Similar Threads

  1. Graphics View - Scene & Item hierarchy
    By mooreaa in forum Qt Programming
    Replies: 0
    Last Post: 29th June 2008, 23:49
  2. Buttons in Graphics Scene
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 28th November 2007, 19:24
  3. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  4. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  5. QTreeWidget and Graphics scene
    By aamer4yu in forum Qt Programming
    Replies: 7
    Last Post: 21st December 2006, 17:24

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.