PDA

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



TheIndependentAquarius
21st August 2014, 10:56
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?

wysota
21st August 2014, 11:11
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.

TheIndependentAquarius
21st August 2014, 11:39
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.

anda_skoa
21st August 2014, 12:46
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,
_