No, you must start gui elements in the main thread.
It depends on you application what to do exactly. If the app should block until the connection is done you can try something like this:
// setup the dialog like posted
connect(&_tcpScoket, SIGNAL(connected()), &el, SLOT(quit()));
connect(&_tcpScoket, SIGNAL(connected()), &pd, SLOT(cancel()));
This runs a local event loop, it keeps the QApplication running, but blocks the flow of control in the method until the socket is connected (and thus the event loop stops).
You will have to add some error handling (eg. connect to the error signal of the socket) and/or add a QTimer to setup a timeout.
I tried your code, but it did not work.
The first shows only for a second a pop-up after it finished waiting.
With the second i don't know where to call @_tcpScoket.waitForConnected(30000) @? I think el.run() should be el.exec()?
Ahm. The progress dialog is only shown until the initial TCP connection has been set up. This usually takes less than a second on a decent internet connection... How long do you expect that to last in your case?
Mh, i tried to connect to a not given IP. I want to see the dialog while
is active till it times out. At 30000 ms.
In not working code:
But in this 30000ms i don't get updates to my gui. Like i expected. But i'm looking for a way, to have my progressdialog running during this 30000 ms without calling waitForConnected from another thread because i don't want to move my socket from the main thread.
I think it's not possible?