Symbian 设备上 Qt 中 QNetworkAccessManager 出现网络会话错误
我正在尝试在 Qt 4.7 中的 Symbian 移动设备上执行 httpget。
我在 Windows 和 Symbian 模拟器上测试了该程序,它们都可以工作,但是当我在 Symbian 设备上尝试它时,出现错误:
网络会话错误。
当我尝试通过 Symbian 设备中的浏览器执行 httpget 时,它起作用了,并且我看到了该页面。
这是网络代码:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl(Consts::webserviceURL + Consts::servletLogin + "?"
+ Consts::username + "=" + username + "&"
+ Consts::password + "=" + password)));
这是回复完成:
void LoginDialog::replyFinished(QNetworkReply* reply){
qDebug() << "reply finished";
if (reply->error()) {
ui->lbl_loginerror->setText("server niet bereikbaar: " + reply->errorString());
qDebug() << "server niet bereikbaar: " << reply->errorString();
}
else {
....
所有这些的输出:
[Qt Message] reply finished
[Qt Message] server niet bereikbaar: "Network session error."
- 连接没有问题:浏览器测试成功
- 代码没有问题:因为它可以在模拟器上运行
我做错了什么?
编辑
我还将网络服务添加到 .pro
文件中:
symbian {
TARGET.UID3 = 0xeeb46dc7
TARGET.CAPABILITY += networkservices
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x800000
}
I'm trying to do an httpget on a Symbian mobile device in Qt 4.7.
I tested the program on Windows and on the Symbian emulator and they both work, but when I try it on the Symbian device I get an error:
Network session error.
When I try to do the httpget through the browser in the Symbian device it works, and I see the page.
Here is the network code:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl(Consts::webserviceURL + Consts::servletLogin + "?"
+ Consts::username + "=" + username + "&"
+ Consts::password + "=" + password)));
Here is the replyFinished:
void LoginDialog::replyFinished(QNetworkReply* reply){
qDebug() << "reply finished";
if (reply->error()) {
ui->lbl_loginerror->setText("server niet bereikbaar: " + reply->errorString());
qDebug() << "server niet bereikbaar: " << reply->errorString();
}
else {
....
Output of all this:
[Qt Message] reply finished
[Qt Message] server niet bereikbaar: "Network session error."
- Nothing wrong with the connection: browser test succeeds
- Nothing wrong with the code: since it works on emulator
What did I do wrong?
Edit
I also added networkservices to the .pro
file:
symbian {
TARGET.UID3 = 0xeeb46dc7
TARGET.CAPABILITY += networkservices
TARGET.EPOCSTACKSIZE = 0x14000
TARGET.EPOCHEAPSIZE = 0x020000 0x800000
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用以下方法解决了这个问题:
我在
.pro
文件的symbian:{}
部分添加了这一行:I solved it using this:
And I added this line in the
symbian:{}
section in the.pro
file: