Results 1 to 4 of 4

Thread: How to run a code such that it doesn't steal all the focus to itself? [QtQuick/QML]

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to run a code such that it doesn't steal all the focus to itself? [QtQuick/QML]

    I have a C++ class. It inherits a parent class which inherits QQuickItem. Therefore now I can't inherit from QThread since the QQuickItem is already there.
    (Error if tried: Object is an ambiguous base of 'xClass')

    My class has been registered by qmlRegisterType and I can access its methods through QML.

    How to write a piece of code in my C++ class which when I run doesn't steal all the focus to itself?
    Last edited by TheIndependentAquarius; 21st August 2014 at 11:40.

  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: Qthread::wait: Thread tries to wait on itself - Dealing with a Qt thread from QML

    Quote Originally Posted by TheIndependentAquarius View Post
    Also, I have written thread()->start and thread()->wait in its constructor.
    What sense does it have to do that?

    The problem is that I cannot see the run() method being executed. Instead I am seeing a warning as shown in the title.
    That's because thread() returns the thread owning the object and it has nothing to do with the thread you are trying to implement.

    [?] Do I have to call the run() method myself? I was hoping that it'll be called by itself?
    No, just don't call thread()->start() and thread()->wait(). Call start() on the QThread object you created and don't call wait() at all, it makes no sense -- you'd block the original thread until the other one ends which would make using the thread totally pointless as you could have executed the functionality in the original thread instead with exactly the same effect.
    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:

    TheIndependentAquarius (21st August 2014)

  4. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: Qthread::wait: Thread tries to wait on itself - Dealing with a Qt thread from QML

    You replied before I could edit my question. I did not know what I was doing. Now I have edited the question to state the real problem, please see it again now. Thanks.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qthread::wait: Thread tries to wait on itself - Dealing with a Qt thread from QML

    That's a totally different question now, you should have created a new topic.

    The current content of the first posting does not make any sense anymore.

    Cheers,
    _

Similar Threads

  1. Wait Condition Indication to User Using Loading/Wait Message
    By vivek.panchal in forum Qt Programming
    Replies: 4
    Last Post: 14th August 2012, 17:40
  2. Replies: 1
    Last Post: 26th April 2011, 16:45
  3. how to resume QThread::wait()?
    By naturalpsychic in forum Qt Programming
    Replies: 6
    Last Post: 27th January 2011, 00:07
  4. Wait in thread till QTcp socket have some thing to read
    By hasnain in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2010, 13:46
  5. Replies: 3
    Last Post: 19th January 2010, 21:26

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.