Support #3700
closedQtNetwork support
0%
Description
Is Wt has QtNetwork module support? wtwithqt works good with QtCore. And what about QtNetwork (e.g. QNetworkAccessManager) ?
Files
Updated by Koen Deforche over 9 years ago
- Status changed from New to Feedback
Hey,
I have no reason to believe that it shouldn't work. You may need to use the event loop option of WQApplication.
Give it a try?
Regards,
Koen
Updated by Anton Kudryavtsev over 9 years ago
Hi, I try it. But "Program received signal SIGSEGV, Segmentation fault."...
Is there examples with QtNetwork thats work without segmentation fault? I try build Wt in debug mode and run app under GDB.
Updated by Anton Kudryavtsev over 9 years ago
I found the problem. Segmentation fault occures if I try setText ( WText ) from slot replyFinished ( QNetworkAccessManager ). So I have one question... Are there rules how Qt object should interact with Wt.
Thanks.
Updated by Wim Dumon over 9 years ago
Hi,
This sounds like you're modifying an object from a thread that is not attached (Wt requires some TLS variables to be set to session-related pointers) to a WApplication. This attachment happens automatically, so it's a signal that you're probably doing something wrong.
Before a thread makes changes to a widget tree, it must lock the widget tree (see WApplication::UpdateLock). We've noticed that this is often challenging to get right (deadlocks etc), so we introduced an easier method: you can use WServer::post to have functions executed in the context of a particular WApplication. Locking will then be handled automatically by Wt. See e.g. examples/features/broadcast.
Best regards,
Wim.
Updated by Anton Kudryavtsev over 9 years ago
- File hello.C hello.C added
- File QtObject.C QtObject.C added
- File QtObject.h QtObject.h added
Hi Wim,
May be I am doing something wrong. I changed wtwithqt example for simple usage QNetworkAccessManager. Can you see attached files? Seg. fault occures in QtObject::replyFinished( QNetworkReply* reply ) by calling emit greet(QString("try set text"));
Updated by Alan Finley over 9 years ago
As Wim said, you can't access Wt objects from a Qt thread. You should save the Wt session id when you initialize your QtObject
and use WServer::post
to access Wt widgets:
void Dictionary::create()
{
...
qtSender_ = new QtObject(this);
qtSender_->setSessionId(sessionId());
...
}
void QtObject::doGreet(const QString& name)
{
WServer::post(session_id, boost::bind(Dictionary::doGreet, wt_, name));
}
Updated by Koen Deforche about 9 years ago
- Status changed from Feedback to Resolved
Updated by Koen Deforche about 9 years ago
- Status changed from Resolved to Closed