Qt-interest Archive, December 2006
signal/slot problems when adding QTcpServer in a non Qt app
Message 1 in thread
Hello
In a non Qt software, I need to add a QTcpServer object, but I have some
constraints.
I need to use a QTcpServer object and signals/slots mechanism without
QApplication/QCoreApplication in main() (somewhere else is ok) and from
a thread (which is not the main thread).
Is it possible to achieve this? and how?
Here is what i already tried:
I tried to add a class derived from QThread and call exec() in the run()
method. But i got a console message telling me that QEventLoop needed a
QApplication.
So i tried to add a QApplication object in the QThread::run() method and
call its exec() method. But i got a console warning message telling me
that my QCoreApplication was not in the main thread.
In both cases the QTcpServer was running, and a TCP connection was
established, but the signals/slots were not working.
void QTcpServer::incomingConnection ( int socketDescriptor ) [virtual
protected]
was not called in my derived class, which surprised me, as i though this
method was directly called
and
void QTcpServer::newConnection () [signal]
was not calling connected slots, which is understandable as I did not
managed to properly start a QEventLoop
Any experience, advice or help about this subject would be greatly
appreciated.
Thanks.
Loïc Mahé
--
[ signature omitted ]
Message 2 in thread
On Thursday 07 December 2006 17:52, Loïc Mahé wrote:
> Hello
>
> In a non Qt software, I need to add a QTcpServer object, but I have some
> constraints.
>
> I need to use a QTcpServer object and signals/slots mechanism without
> QApplication/QCoreApplication in main() (somewhere else is ok) and from
> a thread (which is not the main thread).
>
> Is it possible to achieve this? and how?
No, it's not possible. You need to have a QApplication for this to work.
--
[ signature omitted ]
Message 3 in thread
Bradley T Hughes a écrit :
> On Thursday 07 December 2006 17:52, Loïc Mahé wrote:
>> Hello
>>
>> In a non Qt software, I need to add a QTcpServer object, but I have some
>> constraints.
>>
>> I need to use a QTcpServer object and signals/slots mechanism without
>> QApplication/QCoreApplication in main() (somewhere else is ok) and from
>> a thread (which is not the main thread).
>>
>> Is it possible to achieve this? and how?
>
> No, it's not possible. You need to have a QApplication for this to work.
>
Is it possible to start a QApplication or QCoreApplication from a thread
(different than the main thread)?
I have a console warning when I try to do this, but the event loop does
not seem to work.
--
[ signature omitted ]
Message 4 in thread
On Friday 08 December 2006 09:22, Loïc Mahé wrote:
> Bradley T Hughes a écrit :
> > On Thursday 07 December 2006 17:52, Loïc Mahé wrote:
> >> Hello
> >>
> >> In a non Qt software, I need to add a QTcpServer object, but I have some
> >> constraints.
> >>
> >> I need to use a QTcpServer object and signals/slots mechanism without
> >> QApplication/QCoreApplication in main() (somewhere else is ok) and from
> >> a thread (which is not the main thread).
> >>
> >> Is it possible to achieve this? and how?
> >
> > No, it's not possible. You need to have a QApplication for this to work.
>
> Is it possible to start a QApplication or QCoreApplication from a thread
> (different than the main thread)?
No, it's not. As mentioned in http://doc.trolltech.com/4.2/threads.html, the
Q(Core)Application must be created in the main() thread.
> I have a console warning when I try to do this, but the event loop does
> not seem to work.
--
[ signature omitted ]