Results 1 to 4 of 4

Thread: Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneously?

  1. #1
    Join Date
    Nov 2010
    Posts
    77
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneously?

    I have a question about thread safety. Is it possible that at some point a QGraphicsScene's mousePressEvent and mouseReleaseEvent functions could be in execution simultaneously? That would have serious implications for the way I write my code. I haven't created any additional threads myself, but since Qt programs always consist of multiple threads it might be possible theoretically that both events are being handled at the same time.

  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: Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneou

    Quote Originally Posted by blooglet View Post
    I have a question about thread safety. Is it possible that at some point a QGraphicsScene's mousePressEvent and mouseReleaseEvent functions could be in execution simultaneously?
    No, there is no such possibility unless you call the one method yourself from implementation of the other.

    but since Qt programs always consist of multiple threads
    That's not true, who told you that?
    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. #3
    Join Date
    Nov 2010
    Posts
    77
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneou

    Quote Originally Posted by wysota View Post
    That's not true, who told you that?
    In Qt Creator's debugger, I can see how many threads are associated with the program. On several occasions, I saw that about 4 threads were running even though I hadn't used QThreads anywhere in my code. I sort of assumed that Qt programs always created multiple threads.

  4. #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: Can a QGraphicsScene's mousePressEvent & mouseReleaseEvent be running simultaneou

    The word 'always' has a very specific meaning that is much different from the word 'sometimes'. It is almost important what the threads do.
    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. sorting two QStringLists simultaneously
    By hokie2012 in forum Qt Programming
    Replies: 7
    Last Post: 6th September 2010, 07:45
  2. QGraphicsScene doesn't respond to mousePressEvent
    By Affenbrotbaum in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2010, 19:56
  3. mousePressEvent & mouseReleaseEvent question
    By MarkoSan in forum Qt Programming
    Replies: 13
    Last Post: 9th December 2009, 07:55
  4. How to redraw QGraphicsScene background in running
    By wisconxing in forum Qt Programming
    Replies: 3
    Last Post: 17th November 2008, 13:10
  5. more network connections simultaneously
    By cmeliak in forum Qt Programming
    Replies: 9
    Last Post: 8th June 2006, 00:17

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.